shared
utils
string
object
is
extension
js
tracking
string
dom
when
selection
position
iframe
event
scroll
console
node
string
project
fs
console
onSwipe
Type:Function
Status:stable
Since:1.0.0
Platform:js
@blackbyte.sugar.js.dom.on
Detect swipes gestures on touch devices.
Params
- $elm*-HTMLElement
The HTMLElement on which to detect the swipe
- cb*-Function
The function to call on swipe. The callback function has as parameter an object that containthe swipe direction like left, right, up and down
- settings{}Partial<TOnSwipeSettings>
Some settings to configure your swipe detection
Example
import { onSwipe } from '@blackbyte/sugar/dom'
onSwipe($elm, (swipe) => {
// check the swipe direction
if (swipe.left) {
// do something...
}
// support : left, right, up, down
// etc...
}, {
threshold : 50
});Settings
- threshold100Number
The swipe threshold
Todo
- enhance the typing of the callbacknormal
- testsnormal
Author
- Olivier Bosselolivier.bossel@gmail.comhttps://blackbyte.space