From a236f459f3bacefcdeefc3e8581e46ea4d974428 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Fri, 8 Nov 2013 11:28:40 -0600 Subject: [PATCH] Only show refresher on drag --- dist/css/ionic.css | 1 + dist/js/ionic.js | 10 +++++++++- js/views/scrollView.js | 10 +++++++++- scss/_scaffolding.scss | 1 + 4 files changed, 20 insertions(+), 2 deletions(-) diff --git a/dist/css/ionic.css b/dist/css/ionic.css index f9620a36b0..5097435fad 100644 --- a/dist/css/ionic.css +++ b/dist/css/ionic.css @@ -2289,6 +2289,7 @@ body, .ionic-body { text-size-adjust: none; } .scroll-refresher { + display: none; overflow: hidden; height: 100px; margin-top: -100px; } diff --git a/dist/js/ionic.js b/dist/js/ionic.js index 23eef8e732..8c0fb7256e 100644 --- a/dist/js/ionic.js +++ b/dist/js/ionic.js @@ -2395,6 +2395,9 @@ window.ionic = { if(this.hasPullToRefresh) { this._refresher = document.querySelector('.scroll-refresher'); this._refresherHeight = parseFloat(this._refresher.firstElementChild.offsetHeight) || 100; + // We always start the refresher hidden + this._isRefresherHidden = true; + if(this._refresher) { this._refresher.classList.remove('scroll-refreshing'); } @@ -2494,10 +2497,15 @@ window.ionic = { if(_this._refresher && newY > 0) { // We are pulling to refresh, so update the refresher //_this._refresher.style[ionic.CSS.TRANSFORM] = 'translate3d(0, ' + newY + 'px, 0)'; + if(_this._isRefresherHidden) { + // Show it only in a drag and if we haven't showed it yet + _this._refresher.style.display = 'block'; + _this._isRefresherHidden = false; + } + if(newY > _this._refresherHeight && !_this._isHoldingRefresh) { _this._isHoldingRefresh = true; // Trigger refresh holding event here - } else { // Trigger refresh open amount var ratio = Math.min(1, newY / _this._refresherHeight); diff --git a/js/views/scrollView.js b/js/views/scrollView.js index 325d90d495..ad9ac7b8a5 100644 --- a/js/views/scrollView.js +++ b/js/views/scrollView.js @@ -486,6 +486,9 @@ if(this.hasPullToRefresh) { this._refresher = document.querySelector('.scroll-refresher'); this._refresherHeight = parseFloat(this._refresher.firstElementChild.offsetHeight) || 100; + // We always start the refresher hidden + this._isRefresherHidden = true; + if(this._refresher) { this._refresher.classList.remove('scroll-refreshing'); } @@ -585,10 +588,15 @@ if(_this._refresher && newY > 0) { // We are pulling to refresh, so update the refresher //_this._refresher.style[ionic.CSS.TRANSFORM] = 'translate3d(0, ' + newY + 'px, 0)'; + if(_this._isRefresherHidden) { + // Show it only in a drag and if we haven't showed it yet + _this._refresher.style.display = 'block'; + _this._isRefresherHidden = false; + } + if(newY > _this._refresherHeight && !_this._isHoldingRefresh) { _this._isHoldingRefresh = true; // Trigger refresh holding event here - } else { // Trigger refresh open amount var ratio = Math.min(1, newY / _this._refresherHeight); diff --git a/scss/_scaffolding.scss b/scss/_scaffolding.scss index 42cfb7d5a2..86ccc5ef2c 100644 --- a/scss/_scaffolding.scss +++ b/scss/_scaffolding.scss @@ -109,6 +109,7 @@ body, .ionic-body { // Scroll refresher (for pull to refresh) .scroll-refresher { + display: none; overflow: hidden; height: 100px; margin-top: -100px;