MCPcopy
hub / github.com/Shopify/draggable / resize

Method resize

src/Plugins/ResizeMirror/ResizeMirror.ts:122–165  ·  view source on GitHub ↗

* Resize function for * @param {DragOverEvent | DragOverContainer} dragEvent * @private

(dragEvent: DragOverEvent | DragOverContainerEvent)

Source from the content-addressed store, hash-verified

120 * @private
121 */
122 private resize(dragEvent: DragOverEvent | DragOverContainerEvent) {
123 requestAnimationFrame(() => {
124 let over: HTMLElement | null = null;
125 const {overContainer} = dragEvent;
126
127 if (this.mirror == null || this.mirror.parentNode == null) {
128 return;
129 }
130
131 if (this.mirror.parentNode !== overContainer) {
132 overContainer.appendChild(this.mirror);
133 }
134
135 if (isDragOverEvent(dragEvent)) {
136 over = dragEvent.over;
137 }
138
139 const overElement =
140 over ||
141 this.draggable.getDraggableElementsForContainer(overContainer)[0];
142
143 if (!overElement) {
144 return;
145 }
146
147 requestNextAnimationFrame(() => {
148 const overRect = overElement.getBoundingClientRect();
149
150 if (
151 this.mirror == null ||
152 (this.lastHeight === overRect.height &&
153 this.lastWidth === overRect.width)
154 ) {
155 return;
156 }
157
158 this.mirror.style.width = `${overRect.width}px`;
159 this.mirror.style.height = `${overRect.height}px`;
160
161 this.lastWidth = overRect.width;
162 this.lastHeight = overRect.height;
163 });
164 });
165 }
166}

Callers 1

onDragOverMethod · 0.95

Calls 3

isDragOverEventFunction · 0.90

Tested by

no test coverage detected