I have tried using kinetic.js and the code below, however when I try this in IE11 it keeps jumping to the top every time I scroll:
$("html").kinetic();
I want to make the page scrollable on tablets and IE10 and 11 so that users can just push the page up to scroll down as you would on mobile devices.
How can I do this in pure-JS or jQuery without it jumping to the top?
You can do this quite simply by recording the position of the mouse when clicked, and the current position when being dragged. Try this:
To prevent text selection while dragging, add the following CSS:
Example fiddle
Update
Here's an version of the above as a jQuery plugin, extended to allow both vertical and horizontal scrolling via the settings. It also allows you to change the
cursor
that's used too.Base on Rory McCrossan's idea, implemented with AngularJS2.
I just like to add. Using Rory's code I made horizontal scrolling.
This code will work on horizontal and vertical mouse drag scroll. It's pretty simple.
Based on the first answer, this is the code for horizontal scroll on mouse drag: