Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

preventPageScroll bound unnecessary events and is now hidden through …

…a convienience method
  • Loading branch information...
commit 327ad2d424b6b8e7f52e733cb8ecade06c8683c6 1 parent 564e300
@pbakaus pbakaus authored
Showing with 17 additions and 20 deletions.
  1. +17 −20 src/viewporter.js
View
37 src/viewporter.js
@@ -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);
};
Please sign in to comment.
Something went wrong with that request. Please try again.