totu / Swipe2Nav

Firefox Add-on to enable two-finger left and right gestures to navigate browser history
MIT License
18 stars 4 forks source link

Requires some margin to trigger #3

Open X-Ryl669 opened 3 years ago

X-Ryl669 commented 3 years ago

If you use a touchpad, it's very hard not to swipe vertically by a little bit while swiping horizontally. Thus, I think this line:

        if (Math.abs(deltaX) > 0 && Math.abs(deltaY) == 0)

should read instead:

        if (Math.abs(deltaX) > horzThreshold && Math.abs(deltaY) < vertThreshold)

or, just take the ratio (if you swipe more on horizontal axis than vertical axis):

        var horzScale = 1e6;
        if (Math.abs(deltaX) / Math.abs(deltaY) > horzScale)
// This works even if deltaY is zero, since +Inf > any number
totu commented 3 years ago

@X-Ryl669 Would you like to make a pull request with the change?