Skip to content

Instantly share code, notes, and snippets.

@bhongy
Last active May 16, 2016 22:16
Show Gist options
  • Save bhongy/8402898e20aad108bfad496ee366f314 to your computer and use it in GitHub Desktop.
Save bhongy/8402898e20aad108bfad496ee366f314 to your computer and use it in GitHub Desktop.
.wrapper {
height: 100vh;
width: 100vw;
background-color: green;
}
<div class="wrapper"></div>
var el = document.querySelector('.wrapper');
var touchDetector = new Hammer(el);
touchDetector.get('swipe').set({
direction: Hammer.DIRECTION_VERTICAL
});
touchDetector.get('press').set({
time: 1000
});
function removeSecondListener() {
console.log('second listener removed');
touchDetector.off('press', secondGesture);
}
var timeoutForSecondGesture;
function firstGesture(e) {
touchDetector.on('press', secondGesture);
timeoutForSecondGesture = setTimeout(removeSecondListener, 2000);
}
function secondGesture(e) {
clearTimeout(timeoutForSecondGesture);
console.log(e);
removeSecondListener();
}
touchDetector.on('swipeup', firstGesture);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment