Coder Social home page Coder Social logo

Comments (1)

loupiote avatar loupiote commented on July 28, 2024

I modified the plugin to resolve the following issues:

  1. prevent spurious swipe events when double-tap is detected. This prevent spurious swipe events when people use the one-finger "double-tap + drag" zoom feature on Firefox.

  2. prevent spurious swipe events when multi-finger gestures are detected. This prevents spurious swipe events when people do zoom-in / zoom-out gestures that could otherwise trigger spurious swipe events.

  3. prevent spurious swipe when people scroll the window by a motion that is not completely vertical (or horizontal for horizontally scrolling window), useful for Chrome.

  4. added an optional trace/log function (quite useful for remote debugging)

  5. added config flags to support passive handler, returned value etc.

  6. fixed a bug: swipeleft/swiperight should occur if abs(dx) >= threshold AND abs(dx) > abs(dy) -- the second part of the condition was missing from the code, sometimes causing swipeleft/swiperight in case where swipeup/swipedown should have occurred.

All this have been tested on Chrome, Firefox, Opera and Safari mobile browsers.

I still have a problem: On Firefox mobile (android), touch events are not sent to the handler if "some" scrolling happens when you swipe, even if you swipe mostly right/left. No such problem with Chrome (on Chrome, events are always sent to the handler, whether they cause a scroll or not - we just need to prevent spurious events when a scroll occurred, which we have implemented).

For FF. It is possible to disable default handling, but in that case scrolling does not happen at all, which is an issue in sites that require vertical scroll support and swipe right/left at the same time (like my site). It may be possible to disable default handling and still send the events for the default handling AFTER they have been processed by the plugin. I have not yet managed to do that... Maybe something like what is described there: https://stackoverflow.com/questions/7610871/how-to-trigger-an-event-after-using-event-preventdefault

I can provide you my code, if you are interested to update your plugin. I feel it is significant improvement for usability, especially with the prevention of spurious events in case of double tab, multi-finger gesture, and gesture causing scroll (on Chrome).

It is the one I currently on my photo website with swiping photos in an album. let me know of the best way to provide the updated code.

from detect_swipe.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.