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

touch - swipe is way to sensistive #530

Closed
knalleDK opened this issue Jan 30, 2013 · 4 comments
Closed

touch - swipe is way to sensistive #530

knalleDK opened this issue Jan 30, 2013 · 4 comments

Comments

@knalleDK
Copy link

on iOS:

it's almost impossible to scroll down without accidentally triggering a horizontal swipe ( = slides to next or previous image).

Any way of disabling triggering the sliding animation (next/prev) when I'm actually scrolling the page?

AND perhaps lowering the sensistivity - so it won't trigger slide animation if i have only swiped 5 pixels or so??

@vv3d0x
Copy link

vv3d0x commented Feb 15, 2013

I think I can help You to solve this problem.
I tried to fix it few days, but nothing to do.
problem in onTouchMove function, it need to fix
original code:
function onTouchMove(e) {
dx = (vertical) ? startX - e.touches[0].pageY : startX - e.touches[0].pageX;
scrolling = (vertical) ? (Math.abs(dx) < Math.abs(e.touches[0].pageX - startY)) : (Math.abs(dx) < Math.abs(e.touches[0].pageY - startY));

      if (!scrolling || Number(new Date()) - startT > 500) {
        e.preventDefault();
        if (!fade && slider.transitions) {
          if (!vars.animationLoop) {
            dx = dx/((slider.currentSlide === 0 && dx < 0 || slider.currentSlide === slider.last && dx > 0) ? (Math.abs(dx)/cwidth+2) : 1);
          }
          slider.setProps(offset + dx, "setTouch");
        }
      }
    }

You need to add next line el.removeEventListener('touchmove', onTouchMove, false);
fixed code:
function onTouchMove(e) {
dx = (vertical) ? startX - e.touches[0].pageY : startX - e.touches[0].pageX;
scrolling = (vertical) ? (Math.abs(dx) < Math.abs(e.touches[0].pageX - startY)) : (Math.abs(dx) < Math.abs(e.touches[0].pageY - startY));
if (!scrolling) {
distance = Math.abs(startX - e.touches[0].pageX);
e.preventDefault();
if (!fade && slider.transitions) {
if (!vars.animationLoop) {
dx = dx/((slider.currentSlide === 0 && dx < 0 || slider.currentSlide === slider.last && dx > 0) ? (Math.abs(dx)/cwidth+2) : 1);
}
slider.setProps(offset + dx, "setTouch");
}
} else {
el.removeEventListener('touchmove', onTouchMove, false);
}
}

@knalleDK
Copy link
Author

Awesome! Thanks. Gonna try it next week :)

Den 15/02/2013 kl. 17.02 skrev Yuri Vvedensky notifications@github.com:

I think I can help You to solve this problem.
I tried to fix it few days, but nothing to do.
problem in onTouchMove function, it need to fix
original code:
function onTouchMove(e) {
dx = (vertical) ? startX - e.touches[0].pageY : startX - e.touches[0].pageX;
scrolling = (vertical) ? (Math.abs(dx) < Math.abs(e.touches[0].pageX -
startY)) : (Math.abs(dx) < Math.abs(e.touches[0].pageY - startY));

  if (!scrolling || Number(new Date()) - startT > 500) {
    e.preventDefault();
    if (!fade && slider.transitions) {
      if (!vars.animationLoop) {
        dx = dx/((slider.currentSlide === 0 && dx < 0 ||

slider.currentSlide === slider.last && dx > 0) ?
(Math.abs(dx)/cwidth+2) : 1);
}
slider.setProps(offset + dx, "setTouch");
}
}
}

You need to add next line el.removeEventListener('touchmove', onTouchMove,
false);
fixed code:
function onTouchMove(e) {
dx = (vertical) ? startX - e.touches[0].pageY : startX - e.touches[0].pageX;
scrolling = (vertical) ? (Math.abs(dx) < Math.abs(e.touches[0].pageX -
startY)) : (Math.abs(dx) < Math.abs(e.touches[0].pageY - startY));
if (!scrolling) {
distance = Math.abs(startX - e.touches[0].pageX);
e.preventDefault();
if (!fade && slider.transitions) {
if (!vars.animationLoop) {
dx = dx/((slider.currentSlide === 0 && dx < 0 || slider.currentSlide ===
slider.last && dx > 0) ? (Math.abs(dx)/cwidth+2) : 1);
}
slider.setProps(offset + dx, "setTouch");
}
} else {
el.removeEventListener('touchmove', onTouchMove, false);
}
}


Reply to this email directly or view it on
GitHubhttps://github.com//issues/530#issuecomment-13613294.

@jpannone
Copy link

Just tested on a current project and it works beautifully. Thanks!

@mattyza mattyza closed this as completed Feb 26, 2013
@todesstoss
Copy link

I can reproduce same issue on Windows Phone 8. I think "msGesture" part should be edited too.

epavlenko pushed a commit to epavlenko/FlexSlider that referenced this issue Jan 5, 2016
This fix is to prevent slider to work when scrolling.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants