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

Initial drag on elements in touch mode leads to scrolling of the complete webpage #1132

Open
KilamMalik42 opened this issue Mar 12, 2021 · 1 comment

Comments

@KilamMalik42
Copy link

When a draggable element is touched and moved for the first time, then the webpage also scrolls. Of course it happens only if the website can scroll, e.g. the page is larger than the visible area.

I can reproduce it with the code below in the ZIP in Chrome. On Desktop you just turn on the mobile emulator in the dev console. I have created a pretty high div so the webpage itself is higher than the visible area. Now click on the blue or red item and drag it vertically -> The page will also scroll. If you drop it and then drag the same item again, it will not scroll. But if you switch to the next item it will scroll again.

Is there anything I can do better in the code? This is just a small test, copied from some codepen, but I got the same problem in a real project which is too large to post here.

drag-raph.zip

@KilamMalik42
Copy link
Author

I was able to solve it outside of Raphael. Not sure if this is the best solution or maybe it is possible to solve in Raphael directly.

The problem is, that the event from dragging is also passed to the webpage itself and processed there as scroll event. This can be avoided by using the css style touch-action:none. By setting this style to the SVG or the DIV above, everything works fine.

The only drawback is, that I can only set this attribute on the complete SVG, not on the elements itself like rect. Therefore when I click in the background and move my finger, the screen won't scroll anymore.

For me thats fine, but I leave this open to decide if there is a better solution.

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

1 participant