Last active
May 16, 2016 22:16
-
-
Save bhongy/8402898e20aad108bfad496ee366f314 to your computer and use it in GitHub Desktop.
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
.wrapper { | |
height: 100vh; | |
width: 100vw; | |
background-color: green; | |
} |
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
<div class="wrapper"></div> |
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
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