Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
doRevertAnimation(callback: () => void, revertDuration: number) {
let mirrorEl = this.mirrorEl!
let finalSourceElRect = this.sourceEl!.getBoundingClientRect() // because autoscrolling might have happened
mirrorEl.style.transition =
'top ' + revertDuration + 'ms,' +
'left ' + revertDuration + 'ms'
applyStyle(mirrorEl, {
left: finalSourceElRect.left,
top: finalSourceElRect.top
})
whenTransitionDone(mirrorEl, () => {
mirrorEl.style.transition = ''
callback()
})
}
assignSegCss(segs: Seg[]) {
for (let seg of segs) {
applyStyle(seg.el, this.generateSegCss(seg))
if (seg.level > 0) {
seg.el.classList.add('fc-time-grid-event-inset')
}
// if the event is short that the title will be cut off,
// attach a className that condenses the title into the time area.
if (seg.eventRange.def.title && seg.bottom - seg.top < 30) {
seg.el.classList.add('fc-short') // TODO: "condensed" is a better name
}
}
}
top = options.top || 0;
if (options.left !== undefined) {
left = options.left;
}
else if (options.right !== undefined) {
left = options.right - elDims.width; // derive the left value from the right value
}
else {
left = 0;
}
// constrain to the view port. if constrained by two edges, give precedence to top/left
top = Math.min(top, clippingRect.bottom - elDims.height - this.margin);
top = Math.max(top, clippingRect.top + this.margin);
left = Math.min(left, clippingRect.right - elDims.width - this.margin);
left = Math.max(left, clippingRect.left + this.margin);
applyStyle(el, {
top: top - origin.top,
left: left - origin.left
});
};
// Triggers a callback. Calls a function in the option hash of the same name.
getMirrorEl(): HTMLElement {
let sourceElRect = this.sourceElRect!
let mirrorEl = this.mirrorEl
if (!mirrorEl) {
mirrorEl = this.mirrorEl = this.sourceEl!.cloneNode(true) as HTMLElement // cloneChildren=true
// we don't want long taps or any mouse interaction causing selection/menus.
// would use preventSelection(), but that prevents selectstart, causing problems.
mirrorEl.classList.add('fc-unselectable')
mirrorEl.classList.add('fc-dragging')
applyStyle(mirrorEl, {
position: 'fixed',
zIndex: this.zIndex,
visibility: '', // in case original element was hidden by the drag effect
boxSizing: 'border-box', // for easy width/height
width: sourceElRect.right - sourceElRect.left, // explicit height in case there was a 'right' value
height: sourceElRect.bottom - sourceElRect.top, // explicit width in case there was a 'bottom' value
right: 'auto', // erase and set width instead
bottom: 'auto', // erase and set height instead
margin: 0
})
this.parentNode.appendChild(mirrorEl)
}
return mirrorEl
}
top = options.top || 0
if (options.left !== undefined) {
left = options.left
} else if (options.right !== undefined) {
left = options.right - elDims.width // derive the left value from the right value
} else {
left = 0
}
// constrain to the view port. if constrained by two edges, give precedence to top/left
top = Math.min(top, clippingRect.bottom - elDims.height - this.margin)
top = Math.max(top, clippingRect.top + this.margin)
left = Math.min(left, clippingRect.right - elDims.width - this.margin)
left = Math.max(left, clippingRect.left + this.margin)
applyStyle(el, {
top: top - origin.top,
left: left - origin.left
})
}