Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Prevent touch event when trying to scroll on touch enabled device
'use strict';
var App = App || {};
App.PhotoContainerView = Backbone.View.extend({
el: '.photos-container',
scrollY: 0,
scrollYD: 0,
events: function(){
var action = (Modernizr.touch) ? 'touchend' : 'click',
e = {};
e[ 'touchstart .lightbox'] = 'setScrollY';
e[ 'touchend .lightbox'] = 'checkForScroll';
return e;
},
setScrollY: function(e){
this.scrollY = $(window).scrollTop();
},
checkForScroll: function(){
this.scrollYD = $(window).scrollTop();
if(this.scrollY !== this.scrollYD){
return false;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment