Skip to content

Instantly share code, notes, and snippets.

@jdnichollsc
Last active November 4, 2019 17:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jdnichollsc/34c38d97974773384d002dc73f0fdf2f to your computer and use it in GitHub Desktop.
Save jdnichollsc/34c38d97974773384d002dc73f0fdf2f to your computer and use it in GitHub Desktop.
Gesture Events
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());
}
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