Skip to content

Instantly share code, notes, and snippets.

@dbismut
Last active April 9, 2018 08:10
Show Gist options
  • Save dbismut/4ff1ac6acc44bbb8705917d29b2f097a to your computer and use it in GitHub Desktop.
Save dbismut/4ff1ac6acc44bbb8705917d29b2f097a to your computer and use it in GitHub Desktop.
Part 3 - Adding listeners for touch events
addListeners = () => {
window.addEventListener('scroll', this.onScroll);
window.addEventListener('touchstart', this.onTouchStart);
window.addEventListener('touchend', this.onTouchEnd);
};
removeListeners = () => {
window.removeEventListener('scroll', this.onScroll);
window.removeEventListener('touchend', this.onTouchEnd);
window.removeEventListener('touchstart', this.onTouchStart);
};
onTouchStart = () => (this.isTouching = true);
onTouchEnd = () => (this.isTouching = false);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment