From 8883c6ccc5877fcc8a55910f77fa04a7742285c0 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Fri, 12 Sep 2014 22:57:30 -0500 Subject: [PATCH] fix(scroll): ensure scrollView objects exist Check if scrollView is null when switching off of tabs view. #2181 --- js/angular/controller/scrollController.js | 6 +++--- js/views/scrollView.js | 2 ++ 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/js/angular/controller/scrollController.js b/js/angular/controller/scrollController.js index e35649215f7..e3635029ce6 100644 --- a/js/angular/controller/scrollController.js +++ b/js/angular/controller/scrollController.js @@ -114,7 +114,7 @@ function($scope, scrollViewOptions, $timeout, $window, $$scrollValueCache, $loca }); $timeout(function() { - scrollView.run(); + scrollView && scrollView.run && scrollView.run(); }); this._rememberScrollId = null; @@ -129,7 +129,7 @@ function($scope, scrollViewOptions, $timeout, $window, $$scrollValueCache, $loca this.resize = function() { return $timeout(resize).then(function() { - $element.triggerHandler('scroll.resize'); + $element && $element.triggerHandler('scroll.resize'); }); }; @@ -204,7 +204,7 @@ function($scope, scrollViewOptions, $timeout, $window, $$scrollValueCache, $loca var values = $$scrollValueCache[this._rememberScrollId]; if (values) { this.resize().then(function() { - scrollView.scrollTo(+values.left, +values.top, shouldAnimate); + scrollView && scrollView.scrollTo && scrollView.scrollTo(+values.left, +values.top, shouldAnimate); }); } }; diff --git a/js/views/scrollView.js b/js/views/scrollView.js index 8e07ffe85b2..b74d971676f 100644 --- a/js/views/scrollView.js +++ b/js/views/scrollView.js @@ -1114,6 +1114,8 @@ ionic.views.Scroll = ionic.views.View.inherit({ }, resize: function() { + if(!this.__container || !this.options) return; + // Update Scroller dimensions for changed content // Add padding to bottom of content this.setDimensions(