//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 } }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter