djett41 / ionic-scroll-sista

An Ionic plugin that hides the header/tabs while scrolling
MIT License
125 stars 38 forks source link

upgrade from version 1.0.2 to 1.0.3, 1.0.4 error #8

Closed TonyLuo closed 9 years ago

TonyLuo commented 9 years ago

My project has 3 tabs, it works well using version 1.0.2. I try to use 1.0.3 or 1.0.4, I get following error.

TypeError: Cannot read property 'scrollTo' of null at ionic-angular.js:7066 at processQueue (angular.js:14634) at angular.js:14650 at completeOutstandingRequest (angular.js:5490) at angular.js:5762

djett41 commented 9 years ago

@TonyLuo upgrade to 1.0.5, just released. This should now be fixed

TonyLuo commented 9 years ago

it still has the same issue after upgrade to 1.0.5 or 1.0.6. I fixed it by moving the scrollDelegate.scrollTop() from $ionicView.beforeEnter to $ionicView.afterEnter

$scope.$parent.$on('$ionicView.beforeEnter', function () {
            if (scrollDelegate) {
              //scrollDelegate.scrollTop();
            }
          });

          /**
           * Ionic sets the active/cached nav-bar AFTER the afterEnter event is called, so we need to set a small
           * timeout to let the nav-bar logic run.
           */
          $scope.$parent.$on('$ionicView.afterEnter', function () {
            initCoordinates();

            $timeout(function () {
              init();
              isNavBarTransitioning = false;
              if (scrollDelegate) {
                scrollDelegate.scrollTop();
              }
            }, 20, false);
          });