Skip to content

Instantly share code, notes, and snippets.

@micwehrle
Forked from bhongy/sequential-touch.css
Created May 16, 2016 22:16
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 micwehrle/e654cf83d27b2ec3e72f33b5ea482b3e to your computer and use it in GitHub Desktop.
Save micwehrle/e654cf83d27b2ec3e72f33b5ea482b3e 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