Comments (9)
Seems good to me. I think I can expose a domRect property in all the events
from neodrag.
Should be fixed now.
About the domRect, I will make a release soon with the fix and this feature included
from neodrag.
Can you make svelte REPL of this example please?
from neodrag.
I figured it out! I interpreted the grid array to be the number of grid divisions (i.e. a 2x2 grid), not the pixel dimensions of each grid block (i.e. an infinite grid with snap points every 2px vertically and 2px horizontally). I would clarify that in the docs for other naive users.
from neodrag.
Thanks, ill update the docs
from neodrag.
I did encounter a second, somewhat related issue though: When using a defined grid, I can't move an item back to its original position. If I move an item from its [0, 0] position, I can't move it back to that origin.
REPL
Am I not setting something correctly?
from neodrag.
Yur right, it's definitely a bug. I'll look into it.
from neodrag.
Thanks for checking it out. I also noticed that when dragging two items on top of each other, they can end up having very slightly different translation distances (different by ~1px or less than a pixel). I think this is a subpixel calculation/rendering difference across browsers.
I was trying to detect if two elements were overlapping after a drag event (so I could move one of them out of the way), but I wasn't getting consistent results when I dragged items on top of each other. This might be easier if the onDragEnd
event returned the expected Cartesian coordinates of the element (i.e. the grid [x,y] coordinates, not just the translation offset). Since the user already provides the pixel size of the grid blocks, returning the coordinates should be relatively trivial.
So, if the user provides a grid of [50, 50] in a bounded container that has a width of 250px, and a height of 150px, you might get coordinates that look like this:
Column1 | Column2 | Column3 | Column4 | Column5 |
---|---|---|---|---|
0, 0 | 1, 0 | 2, 0 | 3, 0 | 4, 0 |
0, 1 | 1, 1 | 2, 1 | 3, 1 | 4, 1 |
0, 2 | 1, 2 | 2, 2 | 3, 2 | 4, 2 |
Then a user could store the coordinates returned from the onDragEnd
event and check if they match another draggable item's stored coordinates, rather than checking the pixels from getBoundClientRect()
or parsing out the element.style.transform
. Instead of comparing offsetX: 534.4325..., offsetY: 200.250...
and offsetX: 534.8762..., offsetY: 200.501...
, I could just compare x: 4, y: 1
and x: 4, y: 1
.
What do you think?
from neodrag.
Released in 2.5.0
from neodrag.
Related Issues (20)
- Recalculate Transform Style onMouseDown HOT 2
- pointercancel should be listened to to stop the drag on neodrag core
- pointermove and pointerup events should be added to the document only after pointerdown
- Is it possible to smooth scroll when a bound position updates? HOT 1
- Support setting bounds when dragged element is bigger than the parent
- Stopping click to pass to child HOT 1
- Question: How to disable on:click when dragging HOT 1
- Question: Multiple windows/draggables bug (inheriting size, etc) HOT 5
- TypeError: this.getOptions is not a function.
- :bug: touchmove event don't work with neodrag HOT 2
- Feature Request: `recomputeBounds.resize` HOT 1
- build error: "draggable" is imported from external module "@neodrag/svelte" but never used... HOT 5
- Error when running jest tests. HOT 2
- ignoreMultitouch:true do not work HOT 6
- Unable to combine draggable with scrollable on mobile
- Wireit
- breaking: Rename events to use _ instead of :
- Selecting box content after it's moved
- Demo apps
- Feature requests for invoking position recalculation manually
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neodrag.