Last active
November 4, 2019 17:21
-
-
Save jdnichollsc/34c38d97974773384d002dc73f0fdf2f to your computer and use it in GitHub Desktop.
Gesture Events
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Hammer from 'hammerjs'; | |
private manager: HammerManager; | |
componentDidLoad() { | |
this.manager = new Hammer(this.button); | |
this.manager.add(new Hammer.Pan({ | |
direction: Hammer.DIRECTION_LEFT, | |
threshold: 0 | |
})); | |
this.manager.on("panstart", () => this.onSwipe(0, 0)); | |
this.manager.on("panmove", (event: HammerInput) => this.onSwipe(event.deltaX, 0)); | |
this.manager.on("panend", () => this.onSwipeEnd()); | |
this.manager.on("press", () => this.onStart()); | |
this.manager.on("pressup", () => this.onStop()); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
createGesture, | |
Gesture | |
} from '@ionic/core'; | |
componentDidLoad() { | |
this.swipeGesture = createGesture({ | |
el: this.button, | |
gestureName: 'drag', | |
gesturePriority: 100, | |
threshold: 5, | |
direction: 'x', | |
onStart: () => this.onSwipe(0, 0), | |
onMove: (e) => e.deltaX < 0 && this.onSwipe(e.deltaX, 0), | |
onEnd: () => this.onSwipeEnd() | |
}) | |
this.swipeGesture.setDisabled(false) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment