swipe back refactor

This commit is contained in:
Adam Bradley
2015-09-17 16:13:51 -05:00
parent 252a5ee747
commit 5fbc142dae
15 changed files with 224 additions and 292 deletions

View File

@@ -84,7 +84,7 @@ export class Activator {
touchEnd(ev) {
let self = this;
if (self.tapPolyfill && self.start && !self.app.isTransitioning()) {
if (self.tapPolyfill && self.start && self.app.isEnabled()) {
let endCoord = pointerCoord(ev);
if (!hasPointerMoved(self.pointerTolerance, self.start, endCoord)) {
@@ -140,7 +140,7 @@ export class Activator {
pointerStart(ev) {
let targetEle = this.getActivatableTarget(ev.target);
if (targetEle && !this.app.isTransitioning()) {
if (targetEle && this.app.isEnabled()) {
this.start = pointerCoord(ev);
this.queueActivate(targetEle);
@@ -179,7 +179,7 @@ export class Activator {
* @return {boolean} True if click event should be allowed, otherwise false.
*/
allowClick(ev) {
if (this.app.isTransitioning()) {
if (!this.app.isEnabled()) {
return false;
}
if (!ev.isIonicTap) {
@@ -257,11 +257,10 @@ export class Activator {
deactivate() {
const self = this;
if (self.app.isTransitioning() && self.deactivateAttempt < 30) {
// the app is actively transitioning, don't bother deactivating
// anything this makes it easier on the GPU so it doesn't
// have to redraw any buttons during a transition
// retry
if (!self.app.isEnabled() && self.deactivateAttempt < 30) {
// the app is actively disabled, so don't bother deactivating anything.
// this makes it easier on the GPU so it doesn't have to redraw any
// buttons during a transition. This will retry in XX milliseconds.
++self.deactivateAttempt;
self.queueDeactivate();

View File

@@ -3,6 +3,7 @@ import {ROUTER_BINDINGS, HashLocationStrategy, LocationStrategy, Router} from 'a
import {IonicConfig} from '../../config/config';
import {IonicPlatform, Platform} from '../../platform/platform';
import {ClickBlock} from '../../util/click-block';
import * as util from '../../util/util';
// injectables
@@ -40,7 +41,7 @@ export class IonicApp {
*/
constructor() {
this.overlays = [];
this._transDone = 0;
this._enableTime = 0;
// Our component registry map
this.components = {};
@@ -77,21 +78,27 @@ export class IonicApp {
}
/**
* Sets if the app is currently transitioning or not. For example
* this is set to `true` while views transition, a modal slides up, an action-menu
* slides up, etc. After the transition completes it is set back to `false`.
* @param {bool} isTransitioning
* Sets if the app is currently enabled or not, meaning if it's
* available to accept new user commands. For example, this is set to `false`
* while views transition, a modal slides up, an action-menu
* slides up, etc. After the transition completes it is set back to `true`.
* @param {bool} isEnabled
* @param {bool} fallback When `isEnabled` is set to `false`, this argument
* is used to set the maximum number of milliseconds that app will wait until
* it will automatically enable the app again. It's basically a fallback incase
* something goes wrong during a transition and the app wasn't re-enabled correctly.
*/
setTransitioning(isTransitioning, msTilDone=800) {
this._transDone = (isTransitioning ? Date.now() + msTilDone : 0);
setEnabled(isEnabled, fallback=700) {
this._enableTime = (isEnabled ? 0 : Date.now() + fallback);
ClickBlock(!isEnabled, fallback + 100);
}
/**
* Boolean if the app is actively transitioning or not.
* @return {bool}
*/
isTransitioning() {
return (this._transDone > Date.now());
isEnabled() {
return (this._enableTime < Date.now());
}
/**

View File

@@ -13,7 +13,6 @@ $z-index-navbar-container: 10 !default;
$z-index-content: 5 !default;
$z-index-toolbar: 10 !default;
$z-index-swipe-handle: 15 !default;
$z-index-toolbar-border: 20 !default;
$z-index-list-border: 50 !default;