Skip to content

Commit

Permalink
Only use width and height of overlay node
Browse files Browse the repository at this point in the history
  • Loading branch information
Clauderic Demers committed Jun 22, 2021
1 parent b5d7813 commit aebfd45
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
15 changes: 11 additions & 4 deletions packages/core/src/components/DndContext/DndContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ export const DndContext = memo(function DndContext({
willRecomputeLayouts
);

const draggingNodeRect = overlayNodeRect ?? activeNodeClientRect;
const draggingNodeRect = overlayNodeRect ?? activeNodeRect;
const modifiedTranslate = applyModifiers(modifiers, {
transform: {
x: translate.x - nodeRectDelta.x,
Expand All @@ -250,9 +250,16 @@ export const DndContext = memo(function DndContext({

const scrollAdjustedTranslate = add(modifiedTranslate, scrollAdjustment);

const translatedRect = draggingNodeRect
? getAdjustedRect(draggingNodeRect, modifiedTranslate)
: null;
const rect =
overlayNodeRect && activeNodeRect
? {
...activeNodeRect,
height: overlayNodeRect.height,
width: overlayNodeRect.width,
}
: activeNodeRect;

const translatedRect = rect ? getAdjustedRect(rect, modifiedTranslate) : null;

const collisionRect = translatedRect
? getAdjustedRect(translatedRect, scrollAdjustment)
Expand Down
3 changes: 3 additions & 0 deletions stories/2 - Presets/Sortable/5-Virtualized.story.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ function Sortable({
overIndex: -1,
isDragOverlay: true,
})}
wrapperStyle={{
padding: 5,
}}
dragOverlay
/>
) : null}
Expand Down

0 comments on commit aebfd45

Please sign in to comment.