Skip to content

Commit

Permalink
preventPageScroll bound unnecessary events and is now hidden through …
Browse files Browse the repository at this point in the history
…a convienience method
  • Loading branch information
pbakaus committed Nov 14, 2012
1 parent 564e300 commit 327ad2d
Showing 1 changed file with 17 additions and 20 deletions.
37 changes: 17 additions & 20 deletions src/viewporter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ var viewporter;

// options
forceDetection: false,

// set to true to prevent page scroll.
preventPageScroll: false,

// constants
ACTIVE: (function() {
Expand Down Expand Up @@ -58,10 +55,26 @@ var viewporter;
},

refresh: function(){
if (_viewporter){
if (_viewporter) {
_viewporter.prepareVisualViewport();
}
},

preventPageScroll: function() {

// prevent page scroll if `preventPageScroll` option was set to `true`
document.body.addEventListener('touchmove', function(event) {
event.preventDefault();
}, false);

// reset page scroll if `preventPageScroll` option was set to `true`
// this is used after showing the address bar on iOS
document.body.addEventListener("touchstart", function() {
_viewporter.prepareVisualViewport();
}, false);

}

};

// if we are on Desktop, no need to go further
Expand Down Expand Up @@ -90,22 +103,6 @@ var viewporter;
cachedOrientation = window.orientation;
}
}, false);


// prevent page scroll if `preventPageScroll` option was set to `true`
document.body.addEventListener('touchmove', function(event) {
if (viewporter.preventPageScroll){
event.preventDefault();
}
}, false);

// reset page scroll if `preventPageScroll` option was set to `true`
// this is used after showing the address bar on iOS
document.body.addEventListener("touchstart", function() {
if (viewporter.preventPageScroll) {
that.prepareVisualViewport();
}
}, false);

};

Expand Down

0 comments on commit 327ad2d

Please sign in to comment.