Check if user is scrolling with trackpad?

后端 未结 5 1103
鱼传尺愫
鱼传尺愫 2020-12-08 23:16

I have created a site where users are able to scroll through a gallery using mouse scroll or arrow up/down. It is working like I want it to, and changing one image pr scroll

5条回答
  •  不知归路
    2020-12-08 23:53

    No, this is not possible. The only solution I can think of is set a limit on the scrolling speed. I'm not going to try and decipher your code but I'd recommend making a timedOut variable initialized to zero which is set to one every time you scroll to a new image. Use a setTimeout() to set it back to zero after, say, 50ms. Before you scroll to a new image, check this timedOut variable and only scroll if it's zero. (Make sure you place your setTimeout inside of the timedOut check, otherwise it will be constantly called every time the mousewheel moves, which is not what you want.)

提交回复
热议问题