swipe back square pants

This commit is contained in:
Adam Bradley
2015-05-21 21:41:04 -05:00
parent 288317a423
commit 498430a22a
4 changed files with 25 additions and 36 deletions

View File

@@ -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);

View File

@@ -58,7 +58,7 @@ class IonicApp {
}
progress(ev) {
this.animation.progress( ev.srcElement.value );
this.animation.progress( parseFloat(ev.srcElement.value) );
}
}

View File

@@ -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) {

View File

@@ -1,27 +0,0 @@
<% var PREFIX = '../../..'; %>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" />
<link rel="stylesheet" href="<%= PREFIX %>/css/ionic.css" />
<% buildConfig.scripts.forEach(function(script) {
var src = script.to || script;
if (!/http/.test(src)) {
%>
<script src="<%= PREFIX %>/lib/<%= src %>"></script>
<% } else { %>
<script src="<%= src %>"></script>
<% } %>
<% }); %>
</head>
<body ion-app>
</body>
<script>
System.config({
traceurOptions: {annotations: true, types: true},
});
System.import('main').catch(console.error.bind(console));
</script>
</html>