| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 1ec38ac commit fe3aeac
9 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -184,6 +184,7 @@ function($scope, | |||
| 184 | 184 | }; | |
| 185 | 185 | ||
| 186 | 186 | self.freezeScroll = scrollView.freeze; | |
| 187 | + self.freezeScrollShut = scrollView.freezeShut; | ||
| 187 | 188 | ||
| 188 | 189 | self.freezeAllScrolls = function(shouldFreeze) { | |
| 189 | 190 | for (var i = 0; i < $ionicScrollDelegate._instances.length; i++) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -157,9 +157,10 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io | |||
| 157 | 157 | // equal 0, otherwise remove the class from the body element | |
| 158 | 158 | $ionicBody.enableClass((percentage !== 0), 'menu-open'); | |
| 159 | 159 | ||
| 160 | - freezeAllScrolls(false); | ||
| 160 | + self.content.setCanScroll(percentage == 0); | ||
| 161 | 161 | }; | |
| 162 | 162 | ||
| 163 | + /* | ||
| 163 | 164 | function freezeAllScrolls(shouldFreeze) { | |
| 164 | 165 | if (shouldFreeze && !self.isScrollFreeze) { | |
| 165 | 166 | $ionicScrollDelegate.freezeAllScrolls(shouldFreeze); | |
@@ -169,6 +170,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io | |||
| 169 | 170 | } | |
| 170 | 171 | self.isScrollFreeze = shouldFreeze; | |
| 171 | 172 | } | |
| 173 | + */ | ||
| 172 | 174 | ||
| 173 | 175 | /** | |
| 174 | 176 | * Open the menu the given pixel amount. | |
@@ -320,8 +322,6 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io | |||
| 320 | 322 | ||
| 321 | 323 | // End a drag with the given event | |
| 322 | 324 | self._endDrag = function(e) { | |
| 323 | - freezeAllScrolls(false); | ||
| 324 | - | ||
| 325 | 325 | if (isAsideExposed) return; | |
| 326 | 326 | ||
| 327 | 327 | if (isDragging) { | |
@@ -359,7 +359,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io | |||
| 359 | 359 | ||
| 360 | 360 | if (isDragging) { | |
| 361 | 361 | self.openAmount(offsetX + (lastX - startX)); | |
| 362 | - freezeAllScrolls(true); | ||
| 362 | + self.content.setCanScroll(false); | ||
| 363 | 363 | } | |
| 364 | 364 | }; | |
| 365 | 365 | ||
@@ -443,7 +443,7 @@ function($scope, $attrs, $ionicSideMenuDelegate, $ionicPlatform, $ionicBody, $io | |||
| 443 | 443 | } | |
| 444 | 444 | ||
| 445 | 445 | // ensure scrolls are unfrozen | |
| 446 | - freezeAllScrolls(false); | ||
| 446 | + self.content.setCanScroll(true); | ||
| 447 | 447 | }); | |
| 448 | 448 | ||
| 449 | 449 | self.initialize({ | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -159,6 +159,8 @@ function($timeout, $controller, $ionicBind, $ionicConfig) { | |||
| 159 | 159 | scrollViewOptions: scrollViewOptions | |
| 160 | 160 | }); | |
| 161 | 161 | ||
| 162 | + $scope.scrollCtrl = scrollCtrl; | ||
| 163 | + | ||
| 162 | 164 | $scope.$on('$destroy', function() { | |
| 163 | 165 | if (scrollViewOptions) { | |
| 164 | 166 | scrollViewOptions.scrollingComplete = noop; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -133,6 +133,22 @@ function($timeout, $ionicGesture, $window) { | |||
| 133 | 133 | element: element[0], | |
| 134 | 134 | onDrag: function() {}, | |
| 135 | 135 | endDrag: function() {}, | |
| 136 | + setCanScroll: function(canScroll) { | ||
| 137 | + var c = $element[0].querySelector('.scroll'); | ||
| 138 | + | ||
| 139 | + if(!c) { | ||
| 140 | + return; | ||
| 141 | + } | ||
| 142 | + | ||
| 143 | + var content = angular.element(c.parentElement); | ||
| 144 | + if(!content) { | ||
| 145 | + return; | ||
| 146 | + } | ||
| 147 | + | ||
| 148 | + // freeze our scroll container if we have one | ||
| 149 | + var scrollScope = content.scope(); | ||
| 150 | + scrollScope.scrollCtrl && scrollScope.scrollCtrl.freezeScrollShut(!canScroll); | ||
| 151 | + }, | ||
| 136 | 152 | getTranslateX: function() { | |
| 137 | 153 | return $scope.sideMenuContentTranslateX || 0; | |
| 138 | 154 | }, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -6,6 +6,8 @@ | |||
| 6 | 6 | ionic.CSS.TRANSITION = []; | |
| 7 | 7 | ionic.CSS.TRANSFORM = []; | |
| 8 | 8 | ||
| 9 | + ionic.EVENTS = {}; | ||
| 10 | + | ||
| 9 | 11 | (function() { | |
| 10 | 12 | ||
| 11 | 13 | // transform | |
@@ -41,6 +43,29 @@ | |||
| 41 | 43 | ionic.CSS.TRANSITIONEND = (isWebkit ? 'webkitTransitionEnd ' : '') + 'transitionend'; | |
| 42 | 44 | })(); | |
| 43 | 45 | ||
| 46 | + (function() { | ||
| 47 | + var touchStartEvent = 'touchstart' | ||
| 48 | + var touchMoveEvent = 'touchmove' | ||
| 49 | + var touchEndEvent = 'touchend' | ||
| 50 | + var touchCancelEvent = 'touchcancel' | ||
| 51 | + if (window.navigator.pointerEnabled) { | ||
| 52 | + touchStartEvent = 'pointerdown'; | ||
| 53 | + touchMoveEvent = 'pointermove'; | ||
| 54 | + touchEndEvent = 'pointerup'; | ||
| 55 | + touchCancelEvent = 'pointercancel'; | ||
| 56 | + } else if (window.navigator.msPointerEnabled) { | ||
| 57 | + touchStartEvent = 'MSPointerDown'; | ||
| 58 | + touchMoveEvent = 'MSPointerMove'; | ||
| 59 | + touchEndEvent = 'MSPointerUp'; | ||
| 60 | + touchCancelEvent = 'MSPointerCancel'; | ||
| 61 | + } | ||
| 62 | + | ||
| 63 | + ionic.EVENTS.touchstart = touchStartEvent; | ||
| 64 | + ionic.EVENTS.touchmove = touchMoveEvent; | ||
| 65 | + ionic.EVENTS.touchend = touchEndEvent; | ||
| 66 | + ionic.EVENTS.touchcancel = touchCancelEvent; | ||
| 67 | + })(); | ||
| 68 | + | ||
| 44 | 69 | // classList polyfill for them older Androids | |
| 45 | 70 | // https://gist.github.com/devongovett/1381839 | |
| 46 | 71 | if (!("classList" in document.documentElement) && Object.defineProperty && typeof HTMLElement !== 'undefined') { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -411,6 +411,9 @@ ionic.views.Scroll = ionic.views.View.inherit({ | |||
| 411 | 411 | return self.options.freeze; | |
| 412 | 412 | }; | |
| 413 | 413 | ||
| 414 | + // We can just use the standard freeze pop in our mouth | ||
| 415 | + self.freezeShut = self.freeze; | ||
| 416 | + | ||
| 414 | 417 | self.setScrollStart = function() { | |
| 415 | 418 | ionic.scroll.isScrolling = Math.abs(ionic.scroll.lastTop - self.__scrollTop) > 1; | |
| 416 | 419 | clearTimeout(self.scrollTimer); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -9,6 +9,8 @@ | |||
| 9 | 9 | var self = this; | |
| 10 | 10 | self.__container = self.el = options.el; | |
| 11 | 11 | self.__content = options.el.firstElementChild; | |
| 12 | + // Whether scrolling is frozen or not | ||
| 13 | + self.__frozen = false; | ||
| 12 | 14 | self.isNative = true; | |
| 13 | 15 | ||
| 14 | 16 | self.__scrollTop = self.el.scrollTop; | |
@@ -60,7 +62,13 @@ | |||
| 60 | 62 | }, 80); | |
| 61 | 63 | }; | |
| 62 | 64 | ||
| 63 | - self.freeze = NOOP; | ||
| 65 | + self.freeze = function(shouldFreeze) { | ||
| 66 | + self.__frozen = shouldFreeze; | ||
| 67 | + }; | ||
| 68 | + // A more powerful freeze pop that dominates all other freeze pops | ||
| 69 | + self.freezeShut = function(shouldFreezeShut) { | ||
| 70 | + self.__frozenShut = shouldFreezeShut; | ||
| 71 | + }; | ||
| 64 | 72 | ||
| 65 | 73 | self.__initEventHandlers(); | |
| 66 | 74 | }, | |
@@ -442,12 +450,23 @@ | |||
| 442 | 450 | self.resize(); | |
| 443 | 451 | }; | |
| 444 | 452 | ||
| 453 | + self.handleTouchMove = function(e) { | ||
| 454 | + if(self.__frozen || self.__frozenShut) { | ||
| 455 | + e.preventDefault(); | ||
| 456 | + e.stopPropagation(); | ||
| 457 | + return false; | ||
| 458 | + } | ||
| 459 | + } | ||
| 460 | + | ||
| 445 | 461 | container.addEventListener('scroll', self.onScroll); | |
| 446 | 462 | ||
| 447 | 463 | //Broadcasted when keyboard is shown on some platforms. | |
| 448 | 464 | //See js/utils/keyboard.js | |
| 449 | 465 | container.addEventListener('scrollChildIntoView', self.scrollChildIntoView); | |
| 450 | 466 | ||
| 467 | + container.addEventListener(ionic.EVENTS.touchstart, self.handleTouchMove); | ||
| 468 | + container.addEventListener(ionic.EVENTS.touchmove, self.handleTouchMove); | ||
| 469 | + | ||
| 451 | 470 | // Listen on document because container may not have had the last | |
| 452 | 471 | // keyboardActiveElement, for example after closing a modal with a focused | |
| 453 | 472 | // input and returning to a previously resized scroll view in an ion-content. | |
@@ -466,6 +485,9 @@ | |||
| 466 | 485 | container.removeEventListener('scrollChildIntoView', self.scrollChildIntoView); | |
| 467 | 486 | container.removeEventListener('resetScrollView', self.resetScrollView); | |
| 468 | 487 | ||
| 488 | + container.removeEventListener(ionic.EVENTS.touchstart, self.handleTouchMove); | ||
| 489 | + container.removeEventListener(ionic.EVENTS.touchmove, self.handleTouchMove); | ||
| 490 | + | ||
| 469 | 491 | ionic.tap.removeClonedInputs(container, self); | |
| 470 | 492 | ||
| 471 | 493 | delete self.__container; | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -35,7 +35,12 @@ | |||
| 35 | 35 | .menu-open .menu-content .pane, | |
| 36 | 36 | .menu-open .menu-content .scroll-content { | |
| 37 | 37 | pointer-events: none; | |
| 38 | - //overflow: hidden; | ||
| 38 | + } | ||
| 39 | + .menu-open .menu-content .scroll-content .scroll { | ||
| 40 | + pointer-events: none; | ||
| 41 | + } | ||
| 42 | + .menu-open .menu-content .scroll-content:not(.overflow-scroll) { | ||
| 43 | + overflow: hidden; | ||
| 39 | 44 | } | |
| 40 | 45 | ||
| 41 | 46 | .grade-b .menu-content, | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -28,6 +28,9 @@ <h1>Content</h1> | |||
| 28 | 28 | Sup | |
| 29 | 29 | <ion-option-button class="button-positive">Hello</ion-option-button> | |
| 30 | 30 | </ion-item> | |
| 31 | + <a href="#" class="item" ng-repeat="item in list"> | ||
| 32 | + {{item.text}} | ||
| 33 | + </a> | ||
| 31 | 34 | </ion-list> | |
| 32 | 35 | </ion-content> | |
| 33 | 36 | </ion-side-menu-content> | |
| Back | FazBrowse Home | New Git URL |
0 commit comments