-
Notifications
You must be signed in to change notification settings - Fork 301
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
Drag movement does not include pre-threshold movement #314
Comments
Haha I knew this would come at some point, thanks for making this an issue ;) I'm currently working on v10, and although this would be somewhat a breaking change, I'm open to suggestions on how to handle this. I agree that this is debatable, the main reason why I though to not include threshold is because when moving the dragged element, you generally want to respond 1:1 with your pointer. If you include the pre-threshold in the movement, you will experience a jump equivalent to the threshold — unless you animate the jump, but you might have to catchup with the pointer, so this will result in using an animation library during the whole gesture if you see what I mean. However, as you've noted the state does include Or add a common option to all gestures such as |
No problem, thanks for the library work and quick response. I did think someone must have noticed this already... I see your point about catching up with the pointer. In a use case where you're dragging to precisely position something (like mine), it's more important that the element accurately reflect the pointer position. So I think information to allow a consumer to achieve either/both should be exposed on the state. I'm currently stuck on v7 due to pointer events and Safari 12 support (I don't want to add the PEP polyfill while I'm in the middle of untangling Hammer.js from our project, and we should be dropping 12 soon), so I think "displacement" is the more specific and precise word for what's currently called "movement". Introducing that term could be an opportunity to deprecate movement, and introduce a pair of properties containing the word "displacement". This would avoid an inconvenient breaking change, which is nice despite major versions allowing them. But offset is also in the mix here and has the same issue, maybe initial is affected too. The option idea makes it one or the other, which could be limiting, and is a less nice API. |
I'll continue the conversation about the actual issue later, but about Safari 12, try using |
Hey @robatwilliams, back to the pre-threshold movement issue: my thinking would be to just add an option in the config, like: |
Yes, but I'm not sure about this for a few reasons. Are there any other state properties that currently do include the pre-threshold (e.g. Are there use cases where the library user would like to have both? The option makes it one or the other. To have the best API possible though, bearing in mind the inconvenience of breaking changes, let's think it through a bit more. I think including the threshold distance would be the most intuitive behaviour, so ideally this wouldn't be opt-in. We're using the word "movement" to mean "the vector distance this motion has travelled from its origin", for which I believe the correct physics word is "displacement". Movement strictly, although I'm not sure, means a motion having per-axis and absolute velocities, and perhaps a frequency. We have other displacements here too - Given the above, a pair of properties, something like |
I agree with the terminology, As a clarification, So regarding which state attributes include threshold, actually only
I don't think there's a situation where you need |
Hello! I just ran into this issue while writing an e2e test simulating a drag interaction. For example, issuing the following events:
and logging the useDrag state in the callback only results in two events being logged
when adding another mousemove(10,10) event right after the first I get 3 events
I'm using version I'm now calculating the delta myself based on |
Describe the bug
This is more of an issue than a bug; I see this is a popular established library and has had this behaviour for a long time.
The "gesture" starts as soon as the user starts interacting, and the threshold controls when we determine it to be an intentional gesture and call handlers. It doesn't seem intuitive that the threshold also be subtracted from the
movement
/offset
of the gesture, since the gesture had already started before the threshold was reached. The total movement since the start of the gesture is present in_movement
.Use case: multi-pane layout with draggable splitters to resize them.
Background: issue where dragging the panes was a few pixels off. Turned out to be due to
filterTaps
setting a 3pxthreshold
in the config. Confirmed by seeing the panes were further off when manually setting a 10pxthreshold
.Sandbox or Video
n/a
Information:
Checklist:
touch-action: none
to the draggable element.The text was updated successfully, but these errors were encountered: