Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

454 - copying height and width from the computed styles when morphing… #457

Merged
merged 4 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"dist"
],
"description": "*An awesome drag and drop library for Svelte 3 (not using the browser's built-in dnd, thanks god): Rich animations, nested containers, touch support and more *",
"version": "0.9.22",
"version": "0.9.23",
"repository": {
"type": "git",
"url": "git+https://github.com/isaacHagoel/svelte-dnd-action.git"
Expand Down
3 changes: 3 additions & 0 deletions release-notes.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## Svelte Dnd Action - Release Notes
### [0.9.23](https://github.com/isaacHagoel/svelte-dnd-action/pull/457)

Fix morphing when within css grid

### [0.9.22](https://github.com/isaacHagoel/svelte-dnd-action/pull/410)

Expand Down
10 changes: 7 additions & 3 deletions src/helpers/styler.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ export function morphDraggedElementToBeLike(draggedEl, copyFromEl, currentMouseX
left: (currentMouseX - draggedElRect.left) / draggedElRect.width,
top: (currentMouseY - draggedElRect.top) / draggedElRect.height
};
draggedEl.style.height = `${newRect.height}px`;
draggedEl.style.width = `${newRect.width}px`;
// The lines below are commented out because of issue 454 - seems like these rect values take time to update when in grid layout, therefore this gets copied from the computed styles now
// draggedEl.style.height = `${newRect.height}px`;
// draggedEl.style.width = `${newRect.width}px`;
draggedEl.style.left = `${parseFloat(draggedEl.style.left) - relativeDistanceOfMousePointerFromDraggedSides.left * widthChange}px`;
draggedEl.style.top = `${parseFloat(draggedEl.style.top) - relativeDistanceOfMousePointerFromDraggedSides.top * heightChange}px`;
}
Expand All @@ -104,7 +105,10 @@ function copyStylesFromTo(copyFromEl, copyToEl) {
s.startsWith("border") ||
s === "opacity" ||
s === "color" ||
s === "list-style-type"
s === "list-style-type" ||
// copying with and height to make up for rect update timing issues in some browsers
s === "width" ||
s === "height"
)
.forEach(s => copyToEl.style.setProperty(s, computedStyle.getPropertyValue(s), computedStyle.getPropertyPriority(s)));
}
Expand Down