Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (before.mode !== 'FLUID') {
return;
}
if (before.draggableId !== quote.id) {
return;
}
const el: ?HTMLElement = ref.current;
if (!el) {
return;
}
const box: BoxModel = getBox(el);
// want to shrink the item to 200px wide.
// want it to be centered as much as possible to the cursor
const targetWidth: number = 250;
const halfWidth: number = targetWidth / 2;
const distanceToLeft: number = Math.max(
clientSelection.x - box.borderBox.left,
0,
);
el.style.width = `${targetWidth}px`;
// Nothing left to do
if (distanceToLeft < halfWidth) {
return;
}
const getClient = (
targetRef: HTMLElement,
closestScrollable: ?Element,
): BoxModel => {
const base: BoxModel = getBox(targetRef);
// Droppable has no scroll parent
if (!closestScrollable) {
return base;
}
// Droppable is not the same as the closest scrollable
if (targetRef !== closestScrollable) {
return base;
}
// Droppable is scrollable
// Element.getBoundingClient() returns a clipped padding box:
// When not scrollable: the full size of the element
// When scrollable: the visible size of the element
const closest: ?Closest = (() => {
if (!closestScrollable) {
return null;
}
const frameClient: BoxModel = getBox(closestScrollable);
const scrollSize: ScrollSize = {
scrollHeight: closestScrollable.scrollHeight,
scrollWidth: closestScrollable.scrollWidth,
};
return {
client: frameClient,
page: withScroll(frameClient, windowScroll),
scroll: getScroll(closestScrollable),
scrollSize,
shouldClipSubject,
};
})();