0

How can I make the website acts like a mobile/iPad in scrolling behavior, so that instead of selecting text while clicking and moving the pointer, the website should scrolls/swipes according in the same directions.

Thanks in advance

Bilal Halayqa
  • 932
  • 1
  • 6
  • 25

1 Answers1

1

There's a demo of this here it basically involves updateing the scroll position on mousemnove:

var clicked = false, clickY;
$(document).on({
    'mousemove': function(e) {
        clicked && updateScrollPos(e);
    },
    'mousedown': function(e) {
        clicked = true;
        clickY = e.pageY;
    },
    'mouseup': function() {
        clicked = false;
        $('html').css('cursor', 'auto');
    }
});

var updateScrollPos = function(e) {
    $('html').css('cursor', 'row-resize');
    $(window).scrollTop($(window).scrollTop() + (clickY - e.pageY));
}
Anders Elmgren
  • 637
  • 5
  • 12