cubiq / iscroll

Smooth scrolling for the web
http://iscrolljs.com
MIT License
12.87k stars 3.8k forks source link

iscroll snap too fast using trackpad #1177

Open somielwin opened 7 years ago

somielwin commented 7 years ago

My problem is with trackpads. So if I try to scroll with trackpad, the scroll jumps from the first image to the last one.

Is there any way I can change the speed of the trackpad?

Here's my option

myScroll = new IScroll("#scroller-wrapper", { scrollX: true, scrollY: false, momentum: false, mouseWheel: true, snap: '.box-wrap', bounceEasing: 'circular', bounceTime: 1200 });

TotooriaHyperion commented 7 years ago

I have met with some problem like yours, I think you have somehow used scrollTo or scrollBy before first touch. these two method don't update snap's currentPage, this could let it snap to a wrong position near to the initial position.

solution is manually set currentPage.y/x to the target position of scrollTo, after invoke it.

naosk8 commented 6 years ago

Hi, I also have faced the same problem and found the solution! There is an option: "snapSpeed". This is for managing the speed of snap scrolling, which is not written in the docs yet.

Also, it's possible to adjust the easing by adding an option like this:

{
  ...
  snapSpeed: 500,
  bounceEasing: iScroll.utils.ease.circular, // <-
  ...
}

https://github.com/cubiq/iscroll/blob/master/build/iscroll.js#L680