Skip to content

Commit 9b82373

Browse files
Darrell Sandstromzjffun
authored andcommitted
Fix mirror dimensions
when constrainDimensions is active and not using fixed item width When clicking an item, the mirror is added to the container. Calculations are then made to figure out what size the mirror should be. However, since the mirror is already in the container, the container now has an extra item, thus reducing the width of all of the container's items. Hence, the width calculated is too small and doesn't reflect the true source size. Instead, let's initially hide the mirror, figure out the intended width, then show the mirror.
1 parent f8c4e1c commit 9b82373

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/Draggable/Plugins/Mirror/Mirror.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,8 @@ export default class Mirror extends AbstractPlugin {
286286
return {mirrorOffset, initialX, initialY, ...args};
287287
};
288288

289+
mirror.style.display = 'none';
290+
289291
const initialState = {
290292
mirror,
291293
source,
@@ -424,6 +426,7 @@ function resetMirror({mirror, source, options, ...args}) {
424426
offsetWidth = computedSourceStyles.getPropertyValue('width');
425427
}
426428

429+
mirror.style.display = null;
427430
mirror.style.position = 'fixed';
428431
mirror.style.pointerEvents = 'none';
429432
mirror.style.top = 0;

0 commit comments

Comments
 (0)