Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When using touch, if you stop moving your finger it won't snap #100

Closed
tortilaman opened this issue Apr 23, 2016 · 7 comments
Closed

When using touch, if you stop moving your finger it won't snap #100

tortilaman opened this issue Apr 23, 2016 · 7 comments
Labels
Milestone

Comments

@tortilaman
Copy link

I am currently looking into this, but figured more eyes is better, so I'm submitting an issue.

Description

So if you're using a touch device or touchpad on a laptop, if you stop scrolling with your finger (keep it still and on the screen / touchpad) before you release it from the surface, it will scroll as per normally, but it won't snap to a panel. Here is how I initialize panelsnap

//Panelsnap Initialization

var sectOffset = $(window).height() * 0.15;

jQuery(function($) {
    $('body').panelSnap({
        delay: 5,
        directionThreshold: 1,
        offset: sectOffset
    });
});

I realize this is probably a weird initialization, but I'm doing something a little outside the usual, so yeah.

My Findings

I've found that in this situation where there's an issue, the scrollStop() function isn't called, which leads me to believe that the event isn't fired. Perhaps then another event listener needs to be added, or the event listener that this function is bound to needs to be changed.

I'm not intimately familiar with this domain, so I'll do some research and update this if I find a solution. That being said, I'm not sure I will be able to check whether or not this breaks other implementations.

@tortilaman
Copy link
Author

So I figured out the issue. I haven't thoroughly tested this yet, but tentatively it's a relatively simple fix. I would give line numbers, but I'm sure they're different at this point. I can submit a pull request as well if you'd like. Inside the definition of scrollStart and scrollStop changes have been made here around like 630:

$this.on('touchleave touchcancel touchend', function(event) {
    isTouching = false;
    /*setTimeout(function () {
        clearTimeout(timer);
    }, 50);*/
});

$this.on('touchend touchmove scroll', function(event) {//NOTE: Added touchend
    if (isTouching && event.type != 'touchend') {//NOTE: Added second condition.
        return;
    }

Ended up being more straightforward than I thought once I found my way through the code.

@tortilaman
Copy link
Author

Large issue, this only works in Chrome and other webkit browsers.

@tmatijev
Copy link

Anything new on this? For me this plugin is not working on Chrome on iPhone6 at all ... I love this plugin and would be a shame that it is not working on mobile devices ...

@guidobouman
Copy link
Owner

guidobouman commented Jul 14, 2016

@tortilaman Thanks for your work on this one! Your fix made it work on mobile devices? I'm looking into updating this plugin the next couple of days.

@lapa182
Copy link

lapa182 commented Jul 14, 2016

@tortilaman even if it only works on webkit browsers, it helps a lot!

@guidobouman guidobouman added this to the v1.0.0 milestone May 8, 2018
@guidobouman
Copy link
Owner

guidobouman commented May 8, 2018

Fixed in 21bcbe9, this will land with the v1.0 release.

@tortilaman
Copy link
Author

Good to hear this worked out, thanks for the update @guidobouman!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants