From 498430a22a9caba33267dd66c7b7eac4b1618d68 Mon Sep 17 00:00:00 2001 From: Adam Bradley Date: Thu, 21 May 2015 21:41:04 -0500 Subject: [PATCH] swipe back square pants --- ionic/animations/animation.js | 2 +- ionic/components/app/test/animations/index.js | 2 +- ionic/components/nav/nav-base.js | 30 ++++++++++++++----- scripts/e2e/index.template.html | 27 ----------------- 4 files changed, 25 insertions(+), 36 deletions(-) delete mode 100644 scripts/e2e/index.template.html diff --git a/ionic/animations/animation.js b/ionic/animations/animation.js index 22a4447613..87f9779698 100644 --- a/ionic/animations/animation.js +++ b/ionic/animations/animation.js @@ -334,7 +334,7 @@ class Animate { let player = this.player; // passed a number between 0 and 1 - value = Math.max(0, Math.min(1, parseFloat(value))); + value = Math.max(0, Math.min(1, value)); if (value === 1) { player.currentTime = (this._duration * 0.9999); diff --git a/ionic/components/app/test/animations/index.js b/ionic/components/app/test/animations/index.js index 36e6cc0fbe..881c28af0c 100644 --- a/ionic/components/app/test/animations/index.js +++ b/ionic/components/app/test/animations/index.js @@ -58,7 +58,7 @@ class IonicApp { } progress(ev) { - this.animation.progress( ev.srcElement.value ); + this.animation.progress( parseFloat(ev.srcElement.value) ); } } diff --git a/ionic/components/nav/nav-base.js b/ionic/components/nav/nav-base.js index 49e2510f23..50fe556a63 100644 --- a/ionic/components/nav/nav-base.js +++ b/ionic/components/nav/nav-base.js @@ -21,6 +21,7 @@ export class NavBase { this.items = []; this.navCtrl = new NavController(this); this.sbTransition = null; + this.sbActive = false; } set initial(Class) { @@ -156,6 +157,7 @@ export class NavBase { return; } + this.sbActive = true; this.sbResolve = null; // default the direction to "back" @@ -213,6 +215,9 @@ export class NavBase { // cancelled the swipe back, return items to original state leavingItem.state = ACTIVE_STATE; enteringItem.state = CACHED_STATE; + + leavingItem.shouldDestroy = false; + enteringItem.shouldDestroy = false; } // allow clicks again @@ -228,16 +233,27 @@ export class NavBase { swipeBackEnd(completeSwipeBack, progress, playbackRate) { // to reverse the animation use a negative playbackRate - if (!completeSwipeBack) playbackRate = playbackRate * -1; + if (this.sbTransition && this.sbActive) { + this.sbActive = false; - this.sbTransition.playbackRate(playbackRate); + if (progress <= 0) { + this.swipeBackProgress(0.0001); + } else if (progress >= 1) { + this.swipeBackProgress(0.9999); + } - this.sbTransition.play().then(() => { - this.sbResolve && this.sbResolve(completeSwipeBack); - this.sbTransition && this.sbTransition.dispose(); - this.sbResolve = this.sbTransition = null; - }); + if (!completeSwipeBack) { + playbackRate = playbackRate * -1; + } + this.sbTransition.playbackRate(playbackRate); + + this.sbTransition.play().then(() => { + this.sbResolve && this.sbResolve(completeSwipeBack); + this.sbTransition && this.sbTransition.dispose(); + this.sbResolve = this.sbTransition = null; + }); + } } swipeBackProgress(progress) { diff --git a/scripts/e2e/index.template.html b/scripts/e2e/index.template.html deleted file mode 100644 index db0fe436b2..0000000000 --- a/scripts/e2e/index.template.html +++ /dev/null @@ -1,27 +0,0 @@ -<% var PREFIX = '../../..'; %> - - - - - - - - <% buildConfig.scripts.forEach(function(script) { - var src = script.to || script; - if (!/http/.test(src)) { - %> - - <% } else { %> - - <% } %> - <% }); %> - - - - -