mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2026-03-13 10:22:08 +08:00
fix(keyboard): improve keyboard scroll assist
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
import {Injectable, NgZone} from 'angular2/angular2';
|
||||
|
||||
import {Config} from '../config/config';
|
||||
import {Injectable} from 'angular2/angular2';
|
||||
|
||||
|
||||
/**
|
||||
@@ -17,16 +15,11 @@ import {Config} from '../config/config';
|
||||
@Injectable()
|
||||
export class Form {
|
||||
|
||||
constructor(config: Config, zone: NgZone) {
|
||||
this._config = config;
|
||||
this._zone = zone;
|
||||
|
||||
constructor() {
|
||||
this._inputs = [];
|
||||
this._focused = null;
|
||||
|
||||
zone.runOutsideAngular(() => {
|
||||
this.focusCtrl(document);
|
||||
});
|
||||
this.focusCtrl(document);
|
||||
}
|
||||
|
||||
register(input) {
|
||||
@@ -44,31 +37,15 @@ export class Form {
|
||||
}
|
||||
|
||||
focusCtrl(document) {
|
||||
let scrollAssist = this._config.get('scrollAssist');
|
||||
|
||||
// raw DOM fun
|
||||
let focusCtrl = document.createElement('focus-ctrl');
|
||||
focusCtrl.setAttribute('aria-hidden', true);
|
||||
|
||||
if (scrollAssist) {
|
||||
this._tmp = document.createElement('input');
|
||||
this._tmp.tabIndex = -1;
|
||||
focusCtrl.appendChild(this._tmp);
|
||||
}
|
||||
|
||||
this._blur = document.createElement('button');
|
||||
this._blur.tabIndex = -1;
|
||||
focusCtrl.appendChild(this._blur);
|
||||
|
||||
document.body.appendChild(focusCtrl);
|
||||
|
||||
if (scrollAssist) {
|
||||
this._tmp.addEventListener('keydown', (ev) => {
|
||||
ev.preventDefault();
|
||||
ev.stopPropagation();
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
focusOut() {
|
||||
@@ -76,14 +53,6 @@ export class Form {
|
||||
this._blur.focus();
|
||||
}
|
||||
|
||||
setFocusHolder(type) {
|
||||
if (this._tmp && this._config.get('scrollAssist')) {
|
||||
this._tmp.type = type;
|
||||
console.debug('setFocusHolder', this._tmp.type);
|
||||
this._tmp.focus();
|
||||
}
|
||||
}
|
||||
|
||||
setAsFocused(input) {
|
||||
this._focused = input;
|
||||
}
|
||||
|
||||
@@ -74,7 +74,7 @@ export class Keyboard {
|
||||
* focusOutline: false - Do not add the focus-outline
|
||||
*/
|
||||
|
||||
|
||||
let self = this;
|
||||
let isKeyInputEnabled = false;
|
||||
|
||||
function cssClass() {
|
||||
@@ -107,7 +107,7 @@ export class Keyboard {
|
||||
function enableKeyInput() {
|
||||
cssClass();
|
||||
|
||||
this.zone.runOutsideAngular(() => {
|
||||
self.zone.runOutsideAngular(() => {
|
||||
document.removeEventListener('mousedown', pointerDown);
|
||||
document.removeEventListener('touchstart', pointerDown);
|
||||
|
||||
|
||||
@@ -114,9 +114,21 @@ focus-ctrl {
|
||||
width: 9px;
|
||||
left: -9999px;
|
||||
z-index: 9999;
|
||||
pointer-events: none;
|
||||
}
|
||||
}
|
||||
|
||||
.hide-focused-input {
|
||||
flex: 0 0 8px !important;
|
||||
margin: 0 !important;
|
||||
transform: translate3d(-9999px,0,0);
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.cloned-input {
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
|
||||
// Backdrop
|
||||
// --------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user