Coder Social home page Coder Social logo

detect_swipe's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

detect_swipe's Issues

Google recommends using what they call "passive listeners" for touch handlers on mobile devices

Google recommends using what they call "passive listeners" for touch handlers on mobile devices, to improve scrolling performance.

https://developer.chrome.com/en/docs/lighthouse/best-practices/uses-passive-event-listeners/

So I think the plugin code should be changed to use this:

document.addEventListener('touchstart', onTouchStart, {passive: true});
etc...

The vast majority of mobile devices used today support this, and those who want to support other devices could detect if the browser supports it if needed.

Why does this plugin always prevent the default action?

I think it is quite problematic that it isn't possible to choose whether the default swipe action should be prevented or not. What if I want to listen to the swipedown event on the document element to hide the mobile navigation when the user scrolls down? What about parallax scrolling for touch devices, where the scroll/swipe event is used to check the current scrolltop and load or modify content based on the page offset? At the moment all this is not possible, as the plugin prevents regular scrolling completely. The touchWipe plugin, which this one claims to be based upon, considered this and offers the preventDefaultEvents parameter. It would be really great if this plugin would not prevent everything by default, but would leave it to each actual event Listener to stop the event from bubbling up further or not, using proper jQuery syntax like this:

$(document).on('swipedown',  function(event){ event.preventDefault(); /* ... */ });

This would just feel natural to any jQuery developer and opens up lots of possibilities where there were serious limitations before.

Best regards,
Stefan

Propagate touch events to underlying layers (under the layer that captures the swipe events) so that buttons and links still work?

I would like to put a transparent overlay layer over my page, and my page has buttons, links and other clickable objects it it.

I would like swipe gestures to be detected (by the transparent overlay layer), but at the same time, I would like all the touch events to be propagated also to the other layers, so that my buttons and links still work.

Would it be complicated to add an option to do that?

detect_swipe prevents Firefox from scrolling page vertically when vertical swiping

The plug-in prevents Firefox mobile from scrolling page vertically when vertical swiping.

Interestingly other browsers still do the scrolling (which means of course that vertical swipes are not detected correctly by this plugin).

But in my case-use, i just want to detect left-right swipes, and I want up/down swipe to scroll the page, i.e. the default behavior.

My way to fix this was:

  1. remove the call to e.preventDefault() in onTouchMove().

  2. add "return true" at the end of each event handler, so that the default processing occurs.

This fixes the issue with Firefox mobile that was preventing vertical swipes from scrolling the page.

However, I did not try to fix the opposite problem with Chrome, i.e. for people who want to prevent the default page scrolling action while swiping vertically, because in my case I want the default page scroll to occur in that case.

Problem with pinch / zoom gestures

The code works well except that it incorrectly detects swipes when the user does a pinch gesture (to zoom-in / zoom out the display). So there should be some code that detects that the use is using a two fingers gesture, and it should not trigger in that case.

I have a photo site the uses your swipe-left/right code to navigate between photos, but it is now basically impossible to zoom on a photo without triggering a swipe, which goes to another photo.

Do you think this is easily fixable?

NPM?

Hi, thanks for a simple lib! https://github.com/noelboss/featherlight got me here.

My JS workflow relies on NPM though, so it would help me a lot, if I could find detect_swipe there. Would you consider a npm publish?

Thanks again, P!

Prevent default causing page scrolling lock

Basically if I want a fixed sidebar that you swipe left/right to slide out and back in again and I use the body as the swipe target it prevents you from scrolling the page except when you start the drag from a container element.

If you instead try swiping down or up on an element with content in such as an img or a p tag it prevents default entirely and doesn't let you scroll down.

The way around this for me was to disable the prevent default global setting, but then that introduces some unwelcome left/right page movement when trying to open the sidebar.

Is there a way of preventing default for just up and down swipes with your settings? Or will I have to do so manually?

Vertical Scrolling not working

Good day,
I really love your simple plugin, however when i make "preventDefault: true", it prevents the vertical scrolling of my page. I only want to use the plugin for left and right swipe. How do i do that while allowing the page to scroll up and down as normal webpage. Thank you

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.