Skip to content
This repository has been archived by the owner on Dec 26, 2023. It is now read-only.

Trackpad continued scrolling #12

Open
T19490 opened this issue Jan 11, 2019 · 13 comments
Open

Trackpad continued scrolling #12

T19490 opened this issue Jan 11, 2019 · 13 comments
Labels
bug Something isn't working

Comments

@T19490
Copy link

T19490 commented Jan 11, 2019

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).

@Mobius1 Mobius1 added the bug Something isn't working label Jan 11, 2019
@hashkarl
Copy link

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.

@J053Fabi0
Copy link

Same problem here.

@MaxiMilli
Copy link

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

@TuringJest
Copy link

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.

@Mobius1
Copy link
Owner

Mobius1 commented Jun 17, 2019

Thanks, I'll look in to this 👍

@lzambarda
Copy link

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!

@dshields4
Copy link

Any progress on this bug?

@elisafern12
Copy link

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

@hipressure
Copy link

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

@utkarshgill
Copy link

Anyone found a solution?

@sheuschkel
Copy link

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

@jjjinhyeok
Copy link

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

@teddyh-io
Copy link

teddyh-io commented Jul 20, 2022

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.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests