From 8a7db90aafd0b23b629a403cc8b1cfe84b31682b Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Fri, 8 Nov 2013 15:32:50 -0600 Subject: [PATCH] Refresh and refresh callback on content directive --- dist/css/ionic.css | 3 ++- dist/js/ionic-angular.js | 7 +++++-- dist/js/ionic.js | 7 +++++-- js/ext/angular/src/directive/ionicContent.js | 7 +++++-- js/ext/angular/test/content.html | 14 +++++++++++--- js/views/scrollView.js | 7 +++++-- scss/_scaffolding.scss | 1 + 7 files changed, 34 insertions(+), 12 deletions(-) diff --git a/dist/css/ionic.css b/dist/css/ionic.css index 18eaa35b7b..bf15b6937f 100644 --- a/dist/css/ionic.css +++ b/dist/css/ionic.css @@ -2324,7 +2324,8 @@ body, .ionic-body { .scroll-refresher-content { height: 100%; width: 100%; - text-align: center; } + text-align: center; + position: relative; } .scroll-refreshing { -webkit-transition: height 0.1s ease-in-out; } diff --git a/dist/js/ionic-angular.js b/dist/js/ionic-angular.js index b09b470086..00b29efbcc 100644 --- a/dist/js/ionic-angular.js +++ b/dist/js/ionic-angular.js @@ -487,6 +487,7 @@ angular.module('ionic.ui.content', []) replace: true, template: '
', transclude: true, + scope: true, compile: function(element, attr, transclude) { return function($scope, $element, $attr) { var c = $element.eq(0); @@ -512,7 +513,10 @@ angular.module('ionic.ui.content', []) } else { // Otherwise, supercharge this baby! var sv = new ionic.views.Scroll({ - el: $element[0].firstElementChild + el: $element[0].firstElementChild, + onRefresh: function() { + $scope.onRefresh && $scope.onRefresh(); + } }); // Let child scopes access this $scope.scrollView = sv; @@ -530,7 +534,6 @@ angular.module('ionic.ui.content', []) restrict: 'E', replace: true, transclude: true, - scope: true, template: '
' } }) diff --git a/dist/js/ionic.js b/dist/js/ionic.js index 494d8f93ca..9b74cf85bf 100644 --- a/dist/js/ionic.js +++ b/dist/js/ionic.js @@ -2419,6 +2419,7 @@ window.ionic = { this._refresher.style.display = 'none'; } else { this._isRefresherHidden = false; + this._didTriggerRefresh = false; this._refresher.style.display = 'block'; } @@ -2627,12 +2628,14 @@ window.ionic = { _this._refresher.classList.add('scroll-refreshing'); //_this._refresher.style.height = firstChildHeight + 'px'; _this._scrollTo(0, _this._refresherHeight, 100, _this.refreshEasing); - _this.onRefresh && _this.onRefresh(); + if(!_this._didTriggerRefresh) { + _this.onRefresh && _this.onRefresh(); + _this._didTriggerRefresh = true; + } } else { _this._refresher.classList.add('scroll-refreshing'); //_this._refresher.style.height = 0 + 'px'; _this._scrollTo(0, 0, _this.refreshEasingTime, _this.refreshEasing); - _this.onRefresh && _this.onRefresh(); } return; } diff --git a/js/ext/angular/src/directive/ionicContent.js b/js/ext/angular/src/directive/ionicContent.js index e57b87881f..7800d3e2df 100644 --- a/js/ext/angular/src/directive/ionicContent.js +++ b/js/ext/angular/src/directive/ionicContent.js @@ -20,6 +20,7 @@ angular.module('ionic.ui.content', []) replace: true, template: '
', transclude: true, + scope: true, compile: function(element, attr, transclude) { return function($scope, $element, $attr) { var c = $element.eq(0); @@ -45,7 +46,10 @@ angular.module('ionic.ui.content', []) } else { // Otherwise, supercharge this baby! var sv = new ionic.views.Scroll({ - el: $element[0].firstElementChild + el: $element[0].firstElementChild, + onRefresh: function() { + $scope.onRefresh && $scope.onRefresh(); + } }); // Let child scopes access this $scope.scrollView = sv; @@ -63,7 +67,6 @@ angular.module('ionic.ui.content', []) restrict: 'E', replace: true, transclude: true, - scope: true, template: '
' } }) diff --git a/js/ext/angular/test/content.html b/js/ext/angular/test/content.html index b5b3477f99..326492a0c5 100644 --- a/js/ext/angular/test/content.html +++ b/js/ext/angular/test/content.html @@ -42,7 +42,10 @@ #refresh-content { color: #999; text-align: center; - font-size: 20px; + font-size: 48px; + position: absolute; + bottom: 10px; + width: 100%; } @@ -52,9 +55,11 @@
- + - Refreshing +
+ +
  • asdf{{$index}}
  • @@ -73,6 +78,9 @@ }); } $scope.what = {}; + $scope.onRefresh = function() { + console.log('On refresh'); + } }) diff --git a/js/views/scrollView.js b/js/views/scrollView.js index f7484ec633..12e2bafa2e 100644 --- a/js/views/scrollView.js +++ b/js/views/scrollView.js @@ -510,6 +510,7 @@ this._refresher.style.display = 'none'; } else { this._isRefresherHidden = false; + this._didTriggerRefresh = false; this._refresher.style.display = 'block'; } @@ -718,12 +719,14 @@ _this._refresher.classList.add('scroll-refreshing'); //_this._refresher.style.height = firstChildHeight + 'px'; _this._scrollTo(0, _this._refresherHeight, 100, _this.refreshEasing); - _this.onRefresh && _this.onRefresh(); + if(!_this._didTriggerRefresh) { + _this.onRefresh && _this.onRefresh(); + _this._didTriggerRefresh = true; + } } else { _this._refresher.classList.add('scroll-refreshing'); //_this._refresher.style.height = 0 + 'px'; _this._scrollTo(0, 0, _this.refreshEasingTime, _this.refreshEasing); - _this.onRefresh && _this.onRefresh(); } return; } diff --git a/scss/_scaffolding.scss b/scss/_scaffolding.scss index 103b930e99..496d24da60 100644 --- a/scss/_scaffolding.scss +++ b/scss/_scaffolding.scss @@ -118,6 +118,7 @@ body, .ionic-body { height: 100%; width: 100%; text-align: center; + position: relative; //@include display-flex(); //@include align-items(center); }