selleronom / PrecisionTouchPadSwipe

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

Now overflow-x elements are detected and scrolling them is allowed #13

Closed artisticfox8 closed 2 years ago

artisticfox8 commented 2 years ago

Solved https://github.com/selleronom/PrecisionTouchPadSwipe/issues/12 Also when the document itself has a horizontal scrollbar (either because it is viewed in a smaller viewport or because it is panned), scrolling it is allowed

I would be grateful if you informed the users about these improvements in changelogs. I tested the changes throughly, but I still kept the debugging console.log so you can test too and so that users could report potential bugs (afterall, I wrote a lot of new functionality for this - from 50 lines of code to 200)

selleronom commented 2 years ago

Will update the changelog and mention your help, thank you! But I do not think it is a good idea to log to console for a general release. If people want to help reporting bugs it would be better to add an option to enable console logging.

artisticfox8 commented 2 years ago

Will update the changelog and mention your help, thank you! But I do not think it is a good idea to log to console for a general release. If people want to help reporting bugs it would be better to add an option to enable console logging.

Just added that option

artisticfox8 commented 2 years ago

I added the option, so console log outputs only if the Developer Options: Enable logging in DevTools is true. Also, swipe.js is updated to apply new settings as the user changes the settings, using the browser.storage.onChanged.addListener(setData);

selleronom commented 2 years ago

Tested the PR a bit on https://stackoverflow.com/questions/826782/how-to-disable-text-selection-highlighting/4407335#4407335 but I still get navigation events when I'm doing horizontal scroll in the textbox. What can I do to help with troubleshooting?

artisticfox8 commented 2 years ago

https://stackoverflow.com/questions/826782/how-to-disable-text-selection-highlighting/4407335#4407335

Interesting. My idea is that it might be because the horizontal scrollbar appeared when you resized the viewport. The way the script currently works is that it checks for overflow-x elements on page load

artisticfox8 commented 2 years ago

Tested the PR a bit on https://stackoverflow.com/questions/826782/how-to-disable-text-selection-highlighting/4407335#4407335 but I still get navigation events when I'm doing horizontal scroll in the textbox. What can I do to help with troubleshooting?

As the page works for me when I scroll the code in https://stackoverflow.com/a/8099186

artisticfox8 commented 2 years ago

The most important variable in swipe.js is scrollingLeftOrRight it determines if the page can be navigated or not. What is also important is the "flip" text which gets displayed as an error to be noticeable, basically it tells you when the value of scrollingLeftOrRight changes. If the program swipe.js works correctly, it outputs "check works" text to console, when scrolling an overflow x element.

selleronom commented 2 years ago

Leaving a video on imgur to show what I'm experiencing, when I click in the scroll-able window the check works and it won't navigate. If I have made clicks or scrolls outside the window it still navigates when I'm scrolling in the window.

artisticfox8 commented 2 years ago

Leaving a video on imgur to show what I'm experiencing, when I click in the scroll-able window the check works and it won't navigate. If I have made clicks or scrolls outside the window it still navigates when I'm scrolling in the window.

I don't understand. When you swipe on an element which doesn't have overflow-x, the page should and does navigate.

artisticfox8 commented 2 years ago

The code responsible for that is

elem.addEventListener("mouseleave", event => {
        scrollingLeftOrRight = false; //otherwise navigating would be blocked
    });

in listenForScrollEvents

artisticfox8 commented 2 years ago

One thing though, which needs improvement is the MutationObserver, that doesn't fire always when the page navigates (for example on github.com). I don't really know why, My idea is to instead use a simple setTimeout after the swipe navigate has been triggered, with a timeout of 1000 for example. Any load event wouldn't work here, because only parts of the page get reloaded, and not the entire page. If the entire page got reloaded, the listenForScrollEvents would be called on all detected elements on the page, since the script would be reloaded and it would work without these tricks.