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

On iOS drag stops working after press-and-hold gesture fired on it #515

Open
2 tasks done
dmagunov opened this issue Jul 9, 2022 · 6 comments
Open
2 tasks done
Assignees

Comments

@dmagunov
Copy link

dmagunov commented Jul 9, 2022

Describe the bug

On iOS drag stops working after press-and-hold gesture fired on it

Sandbox or Video

Sandbox:
https://codesandbox.io/s/hidden-rain-1h4oc9

Video:

RPReplay_Final1657397116.MP4

Information:

  • Use Gesture version: >= 10.1.6
  • Device: iPhone13 Pro Max
  • OS: iOS 15.5
  • Browser: Chrome

Checklist:

  • I've read the documentation.
  • If this is an issue with drag, I've tried setting touch-action: none to the draggable element.
@dbismut
Copy link
Collaborator

dbismut commented Jul 11, 2022

Any reason why the sandbox isn't using the latest version of the lib?

@dmagunov
Copy link
Author

I just cloned, an existing example, which is failing on the latest version

@dbismut
Copy link
Collaborator

dbismut commented Jul 11, 2022

That example pulls the latest version of the lib while the sandbox you link uses 10.1.6, hence me asking. In any case I'm able to reproduce with the latest version, thanks for posting the bug.

@dmagunov
Copy link
Author

Thanks, just to clarify, an example sandbox is failing on the latest version, that is why I downgraded the library

Screenshot 2022-07-11 at 18 26 17

Screenshot 2022-07-11 at 18 22 44

@dbismut
Copy link
Collaborator

dbismut commented Jul 11, 2022

It's not failing. Codesandbox is failing for some reason. Not sure what happens there but if you fork it and reload the page it works 🤷‍♂️

@reallongnguyen
Copy link

reallongnguyen commented Oct 16, 2023

FYI
I got same issue on the latest version 10.3.0

OS: iOS 17.0.3
Browser: Chrome mobile


Temporary solution

After press-and-hold, Google context menu is opened. So gesture state is still dragging.
I add an interval to cancel gesture if gesture state is still dragging greater than x seconds.

  const lastDrag = useRef<Record<string, any>>({})

  const bind = useDrag(
    ({
      args: [dragItemOrgIndex],
      active,
      movement: [, y],
      dragging,
      cancel,
    }) => {
      // do something

      // save current drag event
      lastDrag.current = {
        cancel,
        dragging,
        timeStamp: Date.now(),
      }
    }
  )

  useEffect(() => {
    const id = setInterval(() => {
      if (!lastDrag.current.dragging) {
        return
      }

      if (
        Date.now() - lastDrag.current.timeStamp > 5000 &&
        lastDrag.current.cancel
      ) {
        lastDrag.current.cancel()
      }
    }, 500)

    return () => {
      clearInterval(id)
    }
  }, [])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants