Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Two-fingered scroll js on touchpad

We have developed a site whcih has a horizontal orientation and are wanting to implement touchpad control with two fingers move left/right.

When you move two fingers left/right on touchpad, the site page is being scrolled left/right. Now we have implemented touchpad control with two fingers move up/down and page scrolled left/right.

How can we change touchpad control with two fingers move from up/down to left/right to scroll site page left/right using js or jQuery?

like image 469
Tatiana Starol Avatar asked Apr 02 '12 13:04

Tatiana Starol


People also ask

How do I enable Scrolling with two fingers on my touchpad?

Two finger scrollOpen the Activities overview and start typing Mouse & Touchpad. Click on Mouse & Touchpad to open the panel. In the Touchpad section, make sure the Touchpad switch is set to on. Switch the Two-finger Scrolling switch to on.

How do I enable the touchpad with two finger Scrolling on HP?

To change the function of this gesture, select Start, select Settings, select Bluetooth & devices, and then select Touchpad. Under Four-finger gestures, in the Swipes box, select a gesture setting.

How do you slide two fingers on a laptop?

Try out these gestures on the touchpad of your Windows 10 laptop. Select an item: Tap on the touchpad. Scroll: Place two fingers on the touchpad and slide horizontally or vertically. Zoom in or out: Place two fingers on the touchpad and pinch in or stretch out.

Why can't I scroll down with two fingers?

If the Touchpad driver is outdated or not installed correctly, it could affect how two-finger scroll works. To fix the problem, you can update, reinstall or roll back the touchpad driver and then check if the feature functions properly again.


1 Answers

I may be a little late but had the same question before I stumbled over this question. A little further investigation lead me to think that the best bet to capture trackpad scrolling would be the wheel event.

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 fiddle that tells you the scroll direction and offset values but prevents the scrolling itself.

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

like image 91
Torsten Walter Avatar answered Oct 13 '22 23:10

Torsten Walter