Two-way scroll js on touchpad

We have developed a website that has a horizontal orientation and want to implement touch panel control with two fingers left / right.

When you move two fingers left / right on the touch panel, the site page scrolls left / right. Now we have implemented the control of the touch panel with two fingers up / down, and the page scrolled left / right.

How can we change the control of the touch panel with two fingers, moving up / down left / right to scroll the page of the site left / right using js or jQuery?

+2
source share
3 answers

, , . , / , .

, , , . , , div , , , none.

0

, script, - , :

$("body").bind("touchstart", function(e) {
    e.preventDefault();
})
0

, , , . , wheel.

function doScroll(e) {
    // positive deltas are top and left
    // down and right are negative

    // horizontal offset    e.deltaX
    // vertical offset      e.deltaY

    console.log(`x:${e.deltaX} y:${e.deltaY}`);

    e.preventDefault(); // disable the actual scrolling
}

window.addEventListener("wheel", doScroll, false);

I have prepared a script that tells you the scroll direction and offset values, but prevents scrolling.

wheel event has a delta property that (at least in Chrome) is momentum sensitive and gives you the current relative scroll offset than the absolute scroll position available in the event scroll.

0
source

All Articles