Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

☸️ wheel gestures and momentum detection

License

NotificationsYou must be signed in to change notification settings

xiel/wheel-gestures

Repository files navigation

wheel gestures animation, link to docs

wheel gestures and momentum detection in the browser

npm (tag)


Installation

Install wheel-gestures using your package manager:

yarn add wheel-gestures# OR npm install wheel-gestures

Usage

Import and create an instance of WheelGestures and then add the element you want to observe.

import{WheelGestures}from'wheel-gestures'// create an instance per elementconstwheelGestures=WheelGestures()// find and observe the element the user can interact withconstelement=window.document.querySelector('.slider')wheelGestures.observe(element)// add your event callbackwheelGestures.on('wheel',(wheelEventState)=>{//...})

There areoptions to customize the behaviour.

WheelEventState

This is the TypeScript type of the WheelEventState object provided. Even if you do not use TypeScript, this might be helpful to see how the data is provided:

exporttypeVectorXYZ=[number,number,number]exportinterfaceWheelEventState{isStart:booleanisMomentum:booleanisEnding:booleanisMomentumCancel:booleanaxisDelta:VectorXYZaxisVelocity:VectorXYZaxisMovement:VectorXYZaxisMovementProjection:VectorXYZevent:WheelEvent|WheelEventDataprevious?:WheelEventState}

Read more in thedocs.

OS & Browsers

  • Mac OS (Chrome, Firefox, Safari, Edge), Magic Mouse, Magic Trackpad
  • Windows (Chrome, Firefox, Edge), Microsoft Precision Touchpads

Prior Art

Other people also thought that it might be helpful for some interactions to be able to distinguish between user initiated wheel events and the ones that are triggered by inertia scroll, but none of the other known libraries delivered results in the precision I needed, so I developed my own solution. Honourable mentions:

About

☸️ wheel gestures and momentum detection

Resources

License

Stars

Watchers

Forks

Contributors5


[8]ページ先頭

©2009-2025 Movatter.jp