OiO.lk Blog javascript How to prevent page scrolling when dragging over the viewport edges
javascript

How to prevent page scrolling when dragging over the viewport edges


When dragging things on the edge of an overflowing page, the page will start scrolling. How to prevent this behavior with native browser functions / styling? It’s OK to work only on Firefox. (I’m writing some userChrome.js script)

For example, open www.wikipedia.org, when there is a vertical scrollbar (which the full page size is larger than the viewport, aka overflowing), if you drag a file from desktop, folder, or whatever onto the top or bottom edge of the viewport, the page will start scrolling. I want to prevent that.

I’ve tried calling event.preventDefault() on the dragover event, but it does not work. Using overflow:hidden can stop it, but I need the page to be scrollable (at least visually). I’m thinking to create a box that with 0 width but only a scrollbar, then synchronize the scroll behavior of them to fake the users, but I’m wondering is there an elegant way.



You need to sign in to view this answers

Exit mobile version