You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want to conditionally call event.preventDefault to cancel scrolling (use case: implementing pull to refresh where my custom behavior only happens at the top of scrollTop). On iOS, I noticed that sometimes (half?), the event passed would have event.cancelable === false and would still scroll while my drag ran.
I noticed that useDrag() only attaches touchstart event at rest. I found this stackoverflow answer that matches my symptoms.
The following patch corrects the issue for me, confirming the diagnosis:
diff --git a/node_modules/@use-gesture/core/dist/actions-76b8683e.esm.js b/node_modules/@use-gesture/core/dist/actions-76b8683e.esm.js
index 9322a47..e5492e2 100644
--- a/node_modules/@use-gesture/core/dist/actions-76b8683e.esm.js+++ b/node_modules/@use-gesture/core/dist/actions-76b8683e.esm.js@@ -826,10 +826,12 @@ class DragEngine extends CoordinatesEngine {
bind(bindFunction) {
const device = this.config.device;
bindFunction(device, 'start', this.pointerDown.bind(this));
- if (this.config.pointerCapture) {+ if (this.config.pointerCapture || this.config.device === 'touch') {
bindFunction(device, 'change', this.pointerMove.bind(this));
bindFunction(device, 'end', this.pointerUp.bind(this));
bindFunction(device, 'cancel', this.pointerUp.bind(this));
+ }+ if (this.config.pointerCapture) {
bindFunction('lostPointerCapture', '', this.pointerUp.bind(this));
}
if (this.config.keys) {
I am not recommending this patch, but this is the workaround I'm using to fix this for now.
If this is an issue with drag, I've tried setting touch-action: none to the draggable element. I did not do this because I want to be able to conditionally choose if the browser's default drag is activated or not.
The text was updated successfully, but these errors were encountered:
stephen
changed the title
When using pointers.touch = true, conditionally calling preventDefault has flaky behavior in iOS
When using pointers.touch = true, conditionally calling preventDefault has flaky behavior in iOS
Dec 5, 2024
Describe the bug
I want to conditionally call
event.preventDefault
to cancel scrolling (use case: implementing pull to refresh where my custom behavior only happens at the top ofscrollTop
). On iOS, I noticed that sometimes (half?), the event passed would haveevent.cancelable === false
and would still scroll while my drag ran.I noticed that
useDrag()
only attachestouchstart
event at rest. I found this stackoverflow answer that matches my symptoms.The following patch corrects the issue for me, confirming the diagnosis:
I am not recommending this patch, but this is the workaround I'm using to fix this for now.
Information:
Checklist:
If this is an issue with drag, I've tried settingI did not do this because I want to be able to conditionally choose if the browser's default drag is activated or not.touch-action: none
to the draggable element.The text was updated successfully, but these errors were encountered: