Note
Help you customize and manage gesture action in web. It can work well with JS, React or Vue
add issues if you need more features :)
Installation
npm install gesture-customizer
OR
yarn add gesture-customizer
Usage
;const callbackFn = {// ...do something}// registry a gesture listener.Gesture;// remove a gesture listener.Gesture;// pause all gesture listenerGesture;// resueme all gesture listenerGesture;
API docs
interface
KeyType
Define the gesture trigger buttons. It can combine with ctrl
and shift
key.
Arguments | description | Accepted Values | Default |
---|---|---|---|
mouseType |
which mouse buttons can trigger callback, L = Left , R = Right , M = Middle (wheel) |
L / R / LR / M |
|
ctrlKey? |
only trigger event when ctrl key was pressed |
boolean |
false |
shiftKey? |
only trigger event when shift key was pressed |
boolean |
false |
interface
GestureAction
Define the mouse move path, only trigger callback when user did action which is satisfied all limitation.
Arguments | description | Accepted Values | Default |
---|---|---|---|
direction |
the mouse move direction | Direction |
|
minDistance? |
Not trigger callback if moving distance is less than minDistance |
number |
100 |
maxDistance? |
Not trigger callback if moving distance is large than maxDistance |
number |
infinity |
maxSpendTime? |
The maxium spends time on user done this action | number |
infinity |
/** T = Top* R = Right* B = Bottom* L = Left*/;
Gesture. registry(keyType, gestureAction[], callback)
registry a gesture listener.
Gesture. remove(keyType, callback)
remove a gesture listener.
Gesture. pause()
pause all gesture listener
Gesture. resume()
resueme all gesture listener
License
MIT