fitbit-gestures - npm
Sun Jun 27 2021 14:09:19 GMT+0000 (Coordinated Universal Time)
Saved by
@redflashcode
//Optional configurations
const tapConfig: TapConfig = {
interval: 250,
threshold: 10
}
const doubleTapConfig: DoubleTapConfig = {
interval: 250,
threshold: 10
}
const longPressConfig: LongPressConfig = {
time: 300,
threshold: 10
}
const slideConfig: SlideConfig = {
threshold: 10
}
const swipeConfig: SwipeConfig = {
threshold: 100
}
const tap = new TapDetector('tapElement', onGesture.bind(this), tapConfig);
const doubleTap = new DoubleTapDetector('doubleTapElement', onGesture.bind(this), doubleTapConfig);
const longPress = new LongPressDetector('longPressElement', onGesture.bind(this));
const slide = new SlideDetector('slideElement', onGesture.bind(this), slideConfig);
const swipe = new SwipeDetector('swipeElement', onGesture.bind(this), swipeConfig);
function onGesture(event: GestureEvent) {
if(event.type === GestureType.Swipe && event.dir === GestureDirection.Down) {
//Do something
} else if(event.type === GestureType.Slide) {
//Do something
}
}
content_copyCOPY
https://www.npmjs.com/package/fitbit-gestures
Comments