Permalink
Browse files

preventPageScroll bound unnecessary events and is now hidden through …

…a convienience method
  • Loading branch information...
1 parent 564e300 commit 327ad2d424b6b8e7f52e733cb8ecade06c8683c6 @pbakaus committed Nov 14, 2012
Showing with 17 additions and 20 deletions.
  1. +17 −20 src/viewporter.js
View
@@ -16,9 +16,6 @@ var viewporter;
// options
forceDetection: false,
-
- // set to true to prevent page scroll.
- preventPageScroll: false,
// constants
ACTIVE: (function() {
@@ -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
@@ -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);
};

0 comments on commit 327ad2d

Please sign in to comment.