diff --git a/ionic/components/content/content.js b/ionic/components/content/content.js index 68f51795c8..dff97dcd6c 100644 --- a/ionic/components/content/content.js +++ b/ionic/components/content/content.js @@ -19,5 +19,6 @@ import { export class Content { constructor() { this.contentClass = true; + console.log('Content!'); } } diff --git a/ionic/components/nav/nav-base.js b/ionic/components/nav/nav-base.js index acc8572b19..8147bb5439 100644 --- a/ionic/components/nav/nav-base.js +++ b/ionic/components/nav/nav-base.js @@ -195,8 +195,6 @@ export class NavBase { // allow clicks again ClickBlock(false); - console.log('transition, canSwipeBack()', this.canSwipeBack()); - // resolve that this push has completed resolve(); }); diff --git a/ionic/util/click-block.js b/ionic/util/click-block.js index 37afec0e75..e80fd9b30e 100644 --- a/ionic/util/click-block.js +++ b/ionic/util/click-block.js @@ -1,5 +1,8 @@ +import {raf} from './dom' + const CSS_CLICK_BLOCK = 'click-block-active'; +const DEFAULT_EXPIRE = 330; let cbEle, fallbackTimerId, pendingShow; function preventClick(ev) { @@ -8,26 +11,40 @@ function preventClick(ev) { } function show(expire) { + pendingShow = true; clearTimeout(fallbackTimerId); - fallbackTimerId = setTimeout(hide, expire || 320); - - if (cbEle) { - cbEle.classList.add(CSS_CLICK_BLOCK); - - } else { - cbEle = document.createElement('div'); - cbEle.className = 'click-block ' + CSS_CLICK_BLOCK; - document.body.appendChild(cbEle); - cbEle.addEventListener('touchstart', preventClick); - cbEle.addEventListener('mousedown', preventClick); - } + fallbackTimerId = setTimeout(hide, expire || DEFAULT_EXPIRE); + raf(addBlock); } function hide() { + pendingShow = false; clearTimeout(fallbackTimerId); - cbEle && cbEle.classList.remove(CSS_CLICK_BLOCK); + raf(removeBlock); } +function addBlock() { + if (pendingShow) { + + if (cbEle) { + cbEle.classList.add(CSS_CLICK_BLOCK); + + } else { + cbEle = document.createElement('div'); + cbEle.className = 'click-block ' + CSS_CLICK_BLOCK; + document.body.appendChild(cbEle); + cbEle.addEventListener('touchstart', preventClick); + cbEle.addEventListener('mousedown', preventClick); + } + pendingShow = false; + } +} + +function removeBlock() { + if (!pendingShow) { + cbEle && cbEle.classList.remove(CSS_CLICK_BLOCK); + } +} export let ClickBlock = function(shouldShow, expire) {