glidejs / glide

A dependency-free JavaScript ES6 slider and carousel. It’s lightweight, flexible and fast. Designed to slide. No less, no more
https://glidejs.com
MIT License
7.33k stars 771 forks source link

Stop scrolling page while swipe #258

Open antonlukin opened 6 years ago

antonlukin commented 6 years ago

As far as I know there is no option to allow swipe only single axe. For example, when I swipe left/right, the page shouldn't scroll and vice versa.

I've checked similar sliders and most of them stopped scroll while swiping left and right direction. Thinking we should add glide option (or custom plugin) to prevent this annoying jumping.

glide-jump

connorbunting commented 6 years ago

Agree with with this as it's very annoying. Similar discussion with potential fixes here: https://github.com/pawelgrzybek/siema/issues/37

antonlukin commented 6 years ago

Any updates here? Unfortunately this behaviour prevent to use glide at full power

robbinjohansson commented 5 years ago

I'm still experiencing this issue even after the fix (27b6a34)

yarn list v1.12.3
└─ @glidejs/glide@3.2.4
mattias-persson commented 5 years ago

Also using v3.2.4 and still experiencing the issue. Would highly appreciate an update on this!

jfbon commented 5 years ago

I noticed the fix referenced for 3.2.4 was anyway removed again here https://github.com/glidejs/glide/commit/4fc497e2b2cd6549b706d21a35a7dc79210c93d5 for 3.2.7.

There doesn't seem to be a way around this issue right now. Any explanation as to why or what we could try would be great. I've tried some workarounds by toggling css properties for overflow or touch-action when the slider events for swipe.start and swipe.end are triggered, but can't get anything to work.

ericmorand commented 5 years ago

It works perfectly well on my device (Android 9). I assume this is only an iOS issue, right?

jfbon commented 5 years ago

Can confirm. i just tested it on Android and it works fine there.

It basically seems like you are able to scroll diagonally on iOS. Once you release your finger after swiping the slider, the page can continue momentum scrolling. It doesn't seem to respect the touchAngle option in Glide either. Maybe it's part of the problem?

ovcharenkovv commented 5 years ago

the same issue for me will be happy like a happy dog after the fix Thank you in adwounce

jeanlouismainguy commented 4 years ago

I'm still experiencing this issue on Safari on iOS as of today, is there any permanent fix or option available?

motion-work commented 2 years ago

any updates on this?

MakingStuffs commented 1 year ago

Complete hack, but this works:

const handleTouchEnd = (event) => {
  event.preventDefault();
  const slider = document.querySelector(".SLIDER_WRAPPER");
  slider?.removeEventListener("touchmove", handleTouchMove);
  slider?.removeEventListener("touchend", handleTouchEnd);
};
const handleTouchMove = (event) => {
  event.preventDefault();
};

const handleTouchStart = (event) => {
  event.preventDefault();
  const slider = document.querySelector(".SLIDER_WRAPPER");
  slider?.addEventListener("touchmove", handleTouchMove);
  slider?.addEventListener("touchend", handleTouchEnd);
};

const listenForTouchStart = () => {
  const slider = document.querySelector(".SLIDER_WRAPPER");
  slider?.removeEventListener("touchstart", handleTouchStart);
  slider?.addEventListener("touchstart", handleTouchStart);
};