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

Method updateAttachClasses

src/js/tether.js:296–365  ·  view source on GitHub ↗
(elementAttach, targetAttach)

Source from the content-addressed store, hash-verified

294 }
295
296 updateAttachClasses(elementAttach, targetAttach) {
297 elementAttach = elementAttach || this.attachment;
298 targetAttach = targetAttach || this.targetAttachment;
299 const sides = ['left', 'top', 'bottom', 'right', 'middle', 'center'];
300 const { classes, classPrefix } = this.options;
301
302 if (!isUndefined(this._addAttachClasses) && this._addAttachClasses.length) {
303 // updateAttachClasses can be called more than once in a position call, so
304 // we need to clean up after ourselves such that when the last defer gets
305 // ran it doesn't add any extra classes from previous calls.
306 this._addAttachClasses.splice(0, this._addAttachClasses.length);
307 }
308
309 if (isUndefined(this._addAttachClasses)) {
310 this._addAttachClasses = [];
311 }
312 this.add = this._addAttachClasses;
313
314 if (elementAttach.top) {
315 this.add.push(
316 `${getClass('element-attached', classes, classPrefix)}-${
317 elementAttach.top
318 }`
319 );
320 }
321 if (elementAttach.left) {
322 this.add.push(
323 `${getClass('element-attached', classes, classPrefix)}-${
324 elementAttach.left
325 }`
326 );
327 }
328 if (targetAttach.top) {
329 this.add.push(
330 `${getClass('target-attached', classes, classPrefix)}-${
331 targetAttach.top
332 }`
333 );
334 }
335 if (targetAttach.left) {
336 this.add.push(
337 `${getClass('target-attached', classes, classPrefix)}-${
338 targetAttach.left
339 }`
340 );
341 }
342
343 this.all = [];
344 sides.forEach((side) => {
345 this.all.push(
346 `${getClass('element-attached', classes, classPrefix)}-${side}`
347 );
348 this.all.push(
349 `${getClass('target-attached', classes, classPrefix)}-${side}`
350 );
351 });
352
353 defer(() => {

Callers 2

positionMethod · 0.95
positionFunction · 0.80

Calls 4

isUndefinedFunction · 0.90
getClassFunction · 0.90
deferFunction · 0.90
updateClassesFunction · 0.90

Tested by

no test coverage detected