MCPcopy Index your code
hub / github.com/shipshapecode/tether / _flipYTogether

Function _flipYTogether

src/js/constraint.js:220–266  ·  view source on GitHub ↗

* Flip Y "together" * @param {object} tAttachment The target attachment * @param {object} eAttachment The element attachment * @param {number[]} bounds Array of bounds of the format [left, top, right, bottom] * @param {number} height * @param targetHeight * @param {number} top * @private

(tAttachment, eAttachment, bounds, height, targetHeight, top)

Source from the content-addressed store, hash-verified

218 * @private
219 */
220function _flipYTogether(tAttachment, eAttachment, bounds, height, targetHeight, top) {
221 if (tAttachment.top === 'top') {
222 if (eAttachment.top === 'bottom' && top < bounds[1]) {
223 top += targetHeight;
224 tAttachment.top = 'bottom';
225
226 top += height;
227 eAttachment.top = 'top';
228
229 } else if (eAttachment.top === 'top' && top + height > bounds[3] && top - (height - targetHeight) >= bounds[1]) {
230 top -= height - targetHeight;
231 tAttachment.top = 'bottom';
232
233 eAttachment.top = 'bottom';
234 }
235 }
236
237 if (tAttachment.top === 'bottom') {
238 if (eAttachment.top === 'top' && top + height > bounds[3]) {
239 top -= targetHeight;
240 tAttachment.top = 'top';
241
242 top -= height;
243 eAttachment.top = 'bottom';
244
245 } else if (eAttachment.top === 'bottom' && top < bounds[1] && top + (height * 2 - targetHeight) <= bounds[3]) {
246 top += height - targetHeight;
247 tAttachment.top = 'top';
248
249 eAttachment.top = 'top';
250
251 }
252 }
253
254 if (tAttachment.top === 'middle') {
255 if (top + height > bounds[3] && eAttachment.top === 'top') {
256 top -= height;
257 eAttachment.top = 'bottom';
258
259 } else if (top < bounds[1] && eAttachment.top === 'bottom') {
260 top += height;
261 eAttachment.top = 'top';
262 }
263 }
264
265 return top;
266}
267
268/**
269 * Get all the initial classes

Callers 2

constraint.spec.jsFile · 0.85
positionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…