selleronom / PrecisionTouchPadSwipe

Enables two-finger swipe (backwards/forwards) in Firefox for Precision Touchpads.
MIT License
8 stars 2 forks source link

One swipe can sometimes register as more than one back/forward button press #6

Closed Nirudha closed 2 years ago

Nirudha commented 3 years ago

Sometimes a swipe generates more than one click of the back or forward button. I tried reducing the sensitivity to see if this helps but that just changes the threshold of detection. I still see multiple back forward movements.

Perhaps there should be an option to only generate one back/forward event per swipe?

artisticfox8 commented 2 years ago

Happens especially often on Wikipedia

artisticfox8 commented 2 years ago

When I browse wikipedia pages, this addon sometimes goes back two wikipedia pages

artisticfox8 commented 2 years ago

I know why the bug happens: its because lastswipe is not persisted when navigating, every content script on every page has its own variables.

artisticfox8 commented 2 years ago

So when I go back on a page and the browser navigates back one page, if my fingers are still on the trackpad swipping, it will go back again, since the difference between Date.now() and last swipe variable is greater than 1000. (The lastSwipe variable is holding the value 0 or some old value on that page).

artisticfox8 commented 2 years ago

The way I know that is that I tested pasting window.history.back(); window.history.back(); window.history.back(); in the devtools console and the browser only went back one page, so its not the event triggering on one page repeatedly, but on diffferent pages, driving to the conclusion in the previous comment.

artisticfox8 commented 2 years ago

I wrote a fix for this, will prepare a pull request. ¨

selleronom commented 2 years ago

Happy to hear that! Have tried to message the lastSwipe to previous pages to fix the issue with multiple navigation events.

selleronom commented 2 years ago

Thanks to @artisticfox8 for fixing the issue with multiple navigation events. Updated and pushed the add-on to Mozilla