diff --git a/ionic/components/app/activator.ts b/ionic/components/app/activator.ts index e0f8695f4e..2edb426d0d 100644 --- a/ionic/components/app/activator.ts +++ b/ionic/components/app/activator.ts @@ -84,7 +84,7 @@ export class Activator { touchEnd(ev) { let self = this; - if (self.tapPolyfill && self.start) { + if (self.tapPolyfill && self.start && !self.app.isTransitioning()) { 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) { + if (targetEle && !this.app.isTransitioning()) { this.start = pointerCoord(ev); this.queueActivate(targetEle); @@ -179,6 +179,9 @@ export class Activator { * @return {boolean} True if click event should be allowed, otherwise false. */ allowClick(ev) { + if (this.app.isTransitioning()) { + return false; + } if (!ev.isIonicTap) { if (this.isDisabledClick()) { return false; diff --git a/ionic/components/app/app.ts b/ionic/components/app/app.ts index ddca7dfbf1..79e7428a67 100644 --- a/ionic/components/app/app.ts +++ b/ionic/components/app/app.ts @@ -241,7 +241,7 @@ function initApp(window, document, config, platform) { setTimeout(function() { // start listening for resizes XXms after the app starts window.addEventListener('resize', function() { - platform.winResize(); + platform.windowResize(); }); }, 2500); diff --git a/ionic/components/content/content.ts b/ionic/components/content/content.ts index 63d3b4f75e..f30851ceee 100644 --- a/ionic/components/content/content.ts +++ b/ionic/components/content/content.ts @@ -2,9 +2,10 @@ import {Component, View, ElementRef} from 'angular2/angular2'; import {Ion} from '../ion'; import {IonicConfig} from '../../config/config'; +import {IonicPlatform} from '../../platform/platform'; import {IonicComponent} from '../../config/annotations'; import {ScrollTo} from '../../animations/scroll-to'; -import {hasFocusedTextInput} from '../../util/dom'; + /** * @name ionContent @@ -37,9 +38,10 @@ export class Content extends Ion { * @param {ElementRef} elementRef A reference to the component's DOM element. * @param {IonicConfig} config The config object to change content's default settings. */ - constructor(elementRef: ElementRef, config: IonicConfig) { + constructor(elementRef: ElementRef, config: IonicConfig, platform: IonicPlatform) { super(elementRef, config); this.scrollPadding = 0; + this.platform = platform; } /** @@ -154,26 +156,17 @@ export class Content extends Ion { if (addPadding > this.scrollPadding) { this.scrollPadding = addPadding; this.scrollElement.style.paddingBottom = addPadding + 'px'; - } - } - /** - * TODO - */ - pollFocus() { - if (hasFocusedTextInput()) { - this.isPollingFocus = true; + if (!this.keyboardPromise) { - setTimeout(() => { - this.pollFocus(); - }, 500); + this.keyboardPromise = this.platform.onKeyboardClose(() => { + if (this) { + this.scrollPadding = 0; + if (this.scrollElement) this.scrollElement.style.paddingBottom = ''; + this.keyboardPromise = null; + } + }); - } else { - this.isPollingFocus = false; - - if (this.scrollPadding) { - this.scrollPadding = 0; - this.scrollElement.style.paddingBottom = ''; } } } diff --git a/ionic/components/text-input/text-input.ts b/ionic/components/text-input/text-input.ts index 4e873b63a2..40e8d56fa2 100644 --- a/ionic/components/text-input/text-input.ts +++ b/ionic/components/text-input/text-input.ts @@ -160,7 +160,7 @@ export class TextInput extends Ion { * @param {Event} ev TODO */ pointerStart(ev) { - if (this.scrollAssist) { + if (this.scrollAssist && !this.app.isTransitioning()) { // remember where the touchstart/mousedown started this.startCoord = dom.pointerCoord(ev); } @@ -171,7 +171,12 @@ export class TextInput extends Ion { * @param {Event} ev TODO */ pointerEnd(ev) { - if (this.scrollAssist && ev.type === 'touchend') { + + if (this.app.isTransitioning()) { + ev.preventDefault(); + ev.stopPropagation(); + + } else if (this.scrollAssist && ev.type === 'touchend') { // get where the touchend/mouseup ended let endCoord = dom.pointerCoord(ev); @@ -395,10 +400,6 @@ export class TextInput extends Ion { if (this.scrollAssist && this.scrollView) { setTimeout(() => { - if (!this.scrollView.isPollingFocus) { - this.scrollView.pollFocus(); - } - this.deregListeners(); this.deregScroll = this.scrollView.addScrollEventListener(this.scrollMove); }, 100); @@ -431,9 +432,8 @@ export class TextInput extends Ion { * @param {boolean} receivedFocus TODO */ receivedFocus(receivedFocus) { - let self = this; - if (receivedFocus && !self.inputHasFocus) { - self.initFocus(); + if (receivedFocus && !this.inputHasFocus) { + this.initFocus(); } else { this.deregListeners(); diff --git a/ionic/platform/platform.ts b/ionic/platform/platform.ts index f98af170bb..922a416707 100644 --- a/ionic/platform/platform.ts +++ b/ionic/platform/platform.ts @@ -145,7 +145,35 @@ export class IonicPlatform { return !this.isPortrait(); } - winResize() { + isKeyboardOpen() { + return dom.hasFocusedTextInput(); + } + + onKeyboardClose(callback) { + const self = this; + + let promise = null; + + if (!callback) { + // a callback wasn't provided, so let's return a promise instead + promise = new Promise(resolve => { callback = resolve; }); + } + + function checkKeyboard() { + if (!self.isKeyboardOpen()) { + callback(); + + } else { + setTimeout(checkKeyboard, 500); + } + } + + setTimeout(checkKeyboard, 100); + + return promise; + } + + windowResize() { let self = this; clearTimeout(self._resizeTimer);