Pageable icon indicating copy to clipboard operation
Pageable copied to clipboard

Trackpad continued scrolling

Open T19490 opened this issue 6 years ago • 13 comments

I've noticed that when scrolling on a trackpad that Pageable has a tendency to scroll through two or more pages (depending on how "aggressive" the scroll gesture was). This is something that I've been able to replicate in multiple browsers (Chrome/Firefox/Safari) and on both Mac and PC.

Should also note that adjusting the swipeThreshold doesn't seem to affect this behavior, and that it is still possible to only scroll one page at a time (albeit with significantly and unnaturally small swipe gestures on the trackpad).

T19490 avatar Jan 11 '19 15:01 T19490

Noticed the same issue, because some devices have an important inertia and keep emitting events for a while (wheel). Playing with the animation timing helped reducing the effect but then the resulting animation was too slow. I wanted to use lodash's debounce with leading edge option, but couldn't override the wheel event handler, which is handled within.

hashkarl avatar Jan 31 '19 12:01 hashkarl

Same problem here.

J053Fabi0 avatar Apr 17 '19 04:04 J053Fabi0

I have the same problem. 'swipeThreshold' doesn't seems to work. Any other ideas?

MaxiMilli avatar Apr 29 '19 08:04 MaxiMilli

This is probably an issue with kinetic scrolling (especially on Apple devices) which always has been problematic. It sends scroll events even after the gesture is completed.

To solve this I think you need to detect the inertia of the scroll and ignore those events. This could help https://github.com/d4nyll/lethargy not sure if it's still maintained though.

Would love to see this implemented, multiple scrolling is super annoying.

TuringJest avatar Jun 17 '19 17:06 TuringJest

Thanks, I'll look in to this 👍

Mobius1 avatar Jun 17 '19 19:06 Mobius1

The only downside to lethargy would be that an intentional strong swipe would only scroll maximum one page. A less elegant solution could be to add an extra config option called something like wheelThreshold and, in the wheel event handler, add a condition which checks if Math.abs(e) > this.config.wheelThreshold. I repeat, that's not elegant but so far I am satisfied with the results I am having locally with Safari running on a Mac. Not sure of the impact of this on other machines (with a mouse). Hope this is helpful in some way!

lzambarda avatar Oct 02 '19 19:10 lzambarda

Any progress on this bug?

dshields4 avatar Dec 20 '19 18:12 dshields4

Hello, would love this to be looked over too +1 :)

elisafern12 avatar May 28 '20 17:05 elisafern12

We can't use pageable.js because of this bug :(

hipressure avatar Jun 19 '20 09:06 hipressure

Anyone found a solution?

utkarshgill avatar Jun 21 '20 21:06 utkarshgill

Any News ? This bug also affects me, i have a logitech mx ergo trackball, which is responsible for too many events

sheuschkel avatar Nov 30 '20 20:11 sheuschkel

My solution is making pageable's wheel event disabled and using js's wheel event, triggerd keydown event(ArrowUp, ArrowDown).

jjjinhyeok avatar Oct 04 '21 17:10 jjjinhyeok

For those who still need help with this issue, I fixed it using suggestions from @TuringJest and @jjjinhyeok. The script disables the wheel event and uses Lethargy to move pages when wheel event is detected.

<script src="https://cdnjs.cloudflare.com/ajax/libs/lethargy/1.0.9/lethargy.min.js"></script>
<script>
	var pageable = new Pageable("your-body", {
                //[other options here]
		events: {
			wheel: false,
		},
	});
	var lethargy = new Lethargy(); 
	function fpScroll(e) {
		e.preventDefault()
		e.stopPropagation();
		if (lethargy.check(e) !== false) {
			if (lethargy.check(e) == 1) {
				pageable.prev();
			} else if (lethargy.check(e) == -1) {
				pageable.next();
			}
		}
	}
	document.addEventListener('mousewheel', fpScroll, {
		passive: false
	});
	document.addEventListener('DOMMouseScroll', fpScroll, {
		passive: false
	});
	document.addEventListener('wheel', fpScroll, {
		passive: false
	});
	document.addEventListener('MozMousePixelScroll', fpScroll, {
		passive: false
	});
</script>

This should disable the wheel event in Pageable and have Lethargy listen to all scroll events and then send a next/prev command when a valid scroll is detected.

teddyh-io avatar Jul 20 '22 08:07 teddyh-io