mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-12-19 05:19:42 +08:00
improve click block, onKeyboardClose
This commit is contained in:
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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 = '';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user