mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-17 18:54:11 +08:00
perf(all): dynamic import
This commit is contained in:
33
core/src/components.d.ts
vendored
33
core/src/components.d.ts
vendored
@ -2265,39 +2265,6 @@ declare global {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
declare global {
|
|
||||||
|
|
||||||
namespace StencilComponents {
|
|
||||||
interface IonInputShims {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface HTMLIonInputShimsElement extends StencilComponents.IonInputShims, HTMLStencilElement {}
|
|
||||||
|
|
||||||
var HTMLIonInputShimsElement: {
|
|
||||||
prototype: HTMLIonInputShimsElement;
|
|
||||||
new (): HTMLIonInputShimsElement;
|
|
||||||
};
|
|
||||||
interface HTMLElementTagNameMap {
|
|
||||||
'ion-input-shims': HTMLIonInputShimsElement;
|
|
||||||
}
|
|
||||||
interface ElementTagNameMap {
|
|
||||||
'ion-input-shims': HTMLIonInputShimsElement;
|
|
||||||
}
|
|
||||||
namespace JSX {
|
|
||||||
interface IntrinsicElements {
|
|
||||||
'ion-input-shims': JSXElements.IonInputShimsAttributes;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
namespace JSXElements {
|
|
||||||
export interface IonInputShimsAttributes extends HTMLAttributes {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
declare global {
|
declare global {
|
||||||
|
|
||||||
namespace StencilComponents {
|
namespace StencilComponents {
|
||||||
|
@ -2,10 +2,10 @@ import { Component, Element, Event, EventEmitter, Listen, Method, Prop } from '@
|
|||||||
import { ActionSheetButton, Animation, AnimationBuilder, Config, CssClassMap, Mode } from '../../interface';
|
import { ActionSheetButton, Animation, AnimationBuilder, Config, CssClassMap, Mode } from '../../interface';
|
||||||
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, isCancel, present } from '../../utils/overlays';
|
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, isCancel, present } from '../../utils/overlays';
|
||||||
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
||||||
import iosEnterAnimation from './animations/ios.enter';
|
import { iosEnterAnimation } from './animations/ios.enter';
|
||||||
import iosLeaveAnimation from './animations/ios.leave';
|
import { iosLeaveAnimation } from './animations/ios.leave';
|
||||||
import mdEnterAnimation from './animations/md.enter';
|
import { mdEnterAnimation } from './animations/md.enter';
|
||||||
import mdLeaveAnimation from './animations/md.leave';
|
import { mdLeaveAnimation } from './animations/md.leave';
|
||||||
|
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Action Sheet Enter Animation
|
* iOS Action Sheet Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Action Sheet Leave Animation
|
* iOS Action Sheet Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -4,7 +4,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* MD Action Sheet Enter Animation
|
* MD Action Sheet Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* MD Action Sheet Leave Animation
|
* MD Action Sheet Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,10 +3,10 @@ import { AlertButton, AlertInput, Animation, AnimationBuilder, Config, CssClassM
|
|||||||
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, isCancel, present } from '../../utils/overlays';
|
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, isCancel, present } from '../../utils/overlays';
|
||||||
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
||||||
|
|
||||||
import iosEnterAnimation from './animations/ios.enter';
|
import { iosEnterAnimation } from './animations/ios.enter';
|
||||||
import iosLeaveAnimation from './animations/ios.leave';
|
import { iosLeaveAnimation } from './animations/ios.leave';
|
||||||
import mdEnterAnimation from './animations/md.enter';
|
import { mdEnterAnimation } from './animations/md.enter';
|
||||||
import mdLeaveAnimation from './animations/md.leave';
|
import { mdLeaveAnimation } from './animations/md.leave';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-alert',
|
tag: 'ion-alert',
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Alert Enter Animation
|
* iOS Alert Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Alert Leave Animation
|
* iOS Alert Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* Md Alert Enter Animation
|
* Md Alert Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* Md Alert Leave Animation
|
* Md Alert Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
// TODO this can be simplified
|
// TODO this can be simplified
|
||||||
&.statusbar-padding {
|
&.statusbar-padding {
|
||||||
.ion-page,
|
.ion-page,
|
||||||
|
> ion-header,
|
||||||
.ion-page > ion-header,
|
.ion-page > ion-header,
|
||||||
ion-tab ion-nav .ion-page > ion-header,
|
|
||||||
ion-menu > .menu-inner,
|
ion-menu > .menu-inner,
|
||||||
ion-menu > .menu-inner > ion-header {
|
ion-menu > .menu-inner > ion-header {
|
||||||
@include toolbar-statusbar-padding($toolbar-ios-height, $toolbar-ios-padding, $content-ios-padding, $app-ios-statusbar-padding);
|
@include toolbar-statusbar-padding($toolbar-ios-height, $toolbar-ios-padding, $content-ios-padding, $app-ios-statusbar-padding);
|
||||||
|
@ -21,6 +21,10 @@ export class App {
|
|||||||
@Prop({ context: 'window' }) win!: Window;
|
@Prop({ context: 'window' }) win!: Window;
|
||||||
@Prop({ context: 'config' }) config!: Config;
|
@Prop({ context: 'config' }) config!: Config;
|
||||||
|
|
||||||
|
componentDidLoad() {
|
||||||
|
loadInputShims(this.win, this.config);
|
||||||
|
}
|
||||||
|
|
||||||
hostData() {
|
hostData() {
|
||||||
const hybrid = isHybrid(this.win);
|
const hybrid = isHybrid(this.win);
|
||||||
const statusBar = this.config.getBoolean('statusbarPadding', hybrid);
|
const statusBar = this.config.getBoolean('statusbarPadding', hybrid);
|
||||||
@ -35,13 +39,17 @@ export class App {
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const device = this.config.getBoolean('isDevice', isDevice(this.win));
|
const device = this.config.getBoolean('isDevice', isDevice(this.win));
|
||||||
const inputShims = this.config.getBoolean('inputShims', needInputShims(this.win));
|
|
||||||
|
|
||||||
return [
|
return [
|
||||||
inputShims && <ion-input-shims></ion-input-shims>,
|
|
||||||
<ion-tap-click></ion-tap-click>,
|
<ion-tap-click></ion-tap-click>,
|
||||||
device && <ion-status-tap></ion-status-tap>,
|
device && <ion-status-tap></ion-status-tap>,
|
||||||
<slot></slot>
|
<slot></slot>
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function loadInputShims(win: Window, config: Config) {
|
||||||
|
const inputShims = config.getBoolean('inputShims', needInputShims(win));
|
||||||
|
if (inputShims) {
|
||||||
|
(await import('../../utils/input-shims/input-shims')).startInputShims(win.document, config);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -1,101 +0,0 @@
|
|||||||
import { Component, Listen, Prop } from '@stencil/core';
|
|
||||||
import { Config } from '../../interface';
|
|
||||||
|
|
||||||
import enableHideCaretOnScroll from './hacks/hide-caret';
|
|
||||||
import enableInputBlurring from './hacks/input-blurring';
|
|
||||||
import enableScrollAssist from './hacks/scroll-assist';
|
|
||||||
import enableScrollPadding from './hacks/scroll-padding';
|
|
||||||
|
|
||||||
const INPUT_BLURRING = true;
|
|
||||||
const SCROLL_ASSIST = true;
|
|
||||||
const SCROLL_PADDING = true;
|
|
||||||
const HIDE_CARET = true;
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
tag: 'ion-input-shims',
|
|
||||||
})
|
|
||||||
export class InputShims {
|
|
||||||
|
|
||||||
private didLoad = false;
|
|
||||||
private hideCaret = false;
|
|
||||||
private scrollAssist = false;
|
|
||||||
private keyboardHeight = 0;
|
|
||||||
private hideCaretMap = new WeakMap<HTMLElement, Function>();
|
|
||||||
private scrollAssistMap = new WeakMap<HTMLElement, Function>();
|
|
||||||
|
|
||||||
@Prop({ context: 'config' }) config!: Config;
|
|
||||||
@Prop({ context: 'document' }) doc!: Document;
|
|
||||||
|
|
||||||
componentDidLoad() {
|
|
||||||
this.keyboardHeight = this.config.getNumber('keyboardHeight', 290);
|
|
||||||
this.scrollAssist = this.config.getBoolean('scrollAssist', true);
|
|
||||||
this.hideCaret = this.config.getBoolean('hideCaretOnScroll', true);
|
|
||||||
|
|
||||||
const inputBlurring = this.config.getBoolean('inputBlurring', true);
|
|
||||||
if (inputBlurring && INPUT_BLURRING) {
|
|
||||||
enableInputBlurring(this.doc);
|
|
||||||
}
|
|
||||||
|
|
||||||
const scrollPadding = this.config.getBoolean('scrollPadding', true);
|
|
||||||
if (scrollPadding && SCROLL_PADDING) {
|
|
||||||
enableScrollPadding(this.doc, this.keyboardHeight);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Input might be already loaded in the DOM before ion-device-hacks did.
|
|
||||||
// At this point we need to look for all the ion-inputs not registered yet
|
|
||||||
// and register them.
|
|
||||||
const inputs = Array.from(this.doc.querySelectorAll('ion-input'));
|
|
||||||
for (const input of inputs) {
|
|
||||||
this.registerInput(input);
|
|
||||||
}
|
|
||||||
this.didLoad = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listen('body:ionInputDidLoad')
|
|
||||||
protected onInputDidLoad(event: any) {
|
|
||||||
if (this.didLoad) {
|
|
||||||
this.registerInput(event.target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Listen('body:ionInputDidUnload')
|
|
||||||
protected onInputDidUnload(event: any) {
|
|
||||||
if (this.didLoad) {
|
|
||||||
this.unregisterInput(event.target);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private registerInput(componentEl: HTMLElement) {
|
|
||||||
const inputEl = componentEl.querySelector('input');
|
|
||||||
const scrollEl = componentEl.closest('ion-scroll');
|
|
||||||
const contentEl = componentEl.closest('ion-content');
|
|
||||||
|
|
||||||
if (!inputEl) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (HIDE_CARET && scrollEl && this.hideCaret && !this.hideCaretMap.has(componentEl)) {
|
|
||||||
const rmFn = enableHideCaretOnScroll(componentEl, inputEl, scrollEl);
|
|
||||||
this.hideCaretMap.set(componentEl, rmFn);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SCROLL_ASSIST && contentEl && this.scrollAssist && !this.scrollAssistMap.has(componentEl)) {
|
|
||||||
const rmFn = enableScrollAssist(componentEl, inputEl, contentEl, this.keyboardHeight);
|
|
||||||
this.scrollAssistMap.set(componentEl, rmFn);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private unregisterInput(componentEl: HTMLElement) {
|
|
||||||
if (HIDE_CARET && this.hideCaret) {
|
|
||||||
const fn = this.hideCaretMap.get(componentEl);
|
|
||||||
fn && fn();
|
|
||||||
this.hideCaretMap.delete(componentEl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (SCROLL_ASSIST && this.scrollAssist) {
|
|
||||||
const fn = this.scrollAssistMap.get(componentEl);
|
|
||||||
fn && fn();
|
|
||||||
this.scrollAssistMap.delete(componentEl);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -4,7 +4,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Loading Enter Animation
|
* iOS Loading Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -4,7 +4,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Loading Leave Animation
|
* iOS Loading Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* Md Loading Enter Animation
|
* Md Loading Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* Md Loading Leave Animation
|
* Md Loading Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,11 +3,11 @@ import { Animation, AnimationBuilder, Config, Mode } from '../../interface';
|
|||||||
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, present } from '../../utils/overlays';
|
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, present } from '../../utils/overlays';
|
||||||
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
||||||
|
|
||||||
import iosEnterAnimation from './animations/ios.enter';
|
import { iosEnterAnimation } from './animations/ios.enter';
|
||||||
import iosLeaveAnimation from './animations/ios.leave';
|
import { iosLeaveAnimation } from './animations/ios.leave';
|
||||||
|
|
||||||
import mdEnterAnimation from './animations/md.enter';
|
import { mdEnterAnimation } from './animations/md.enter';
|
||||||
import mdLeaveAnimation from './animations/md.leave';
|
import { mdLeaveAnimation } from './animations/md.leave';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-loading',
|
tag: 'ion-loading',
|
||||||
|
@ -6,7 +6,7 @@ import { Animation } from '../../../interface';
|
|||||||
* type will provide their own animations for open and close
|
* type will provide their own animations for open and close
|
||||||
* and registers itself with Menu.
|
* and registers itself with Menu.
|
||||||
*/
|
*/
|
||||||
export default function baseAnimation(Animation: Animation): Promise<Animation> {
|
export function baseAnimation(Animation: Animation): Promise<Animation> {
|
||||||
// https://material.io/guidelines/motion/movement.html#movement-movement-in-out-of-screen-bounds
|
// https://material.io/guidelines/motion/movement.html#movement-movement-in-out-of-screen-bounds
|
||||||
// https://material.io/guidelines/motion/duration-easing.html#duration-easing-natural-easing-curves
|
// https://material.io/guidelines/motion/duration-easing.html#duration-easing-natural-easing-curves
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Animation, Menu } from '../../../interface';
|
import { Animation, Menu } from '../../../interface';
|
||||||
import baseAnimation from './base';
|
import { baseAnimation } from './base';
|
||||||
|
|
||||||
const BOX_SHADOW_WIDTH = 8;
|
const BOX_SHADOW_WIDTH = 8;
|
||||||
/**
|
/**
|
||||||
@ -8,7 +8,7 @@ const BOX_SHADOW_WIDTH = 8;
|
|||||||
* The menu slides over the content. The content
|
* The menu slides over the content. The content
|
||||||
* itself, which is under the menu, does not move.
|
* itself, which is under the menu, does not move.
|
||||||
*/
|
*/
|
||||||
export default function(Animation: Animation, _: HTMLElement, menu: Menu): Promise<Animation> {
|
export function menuOverlayAnimation(Animation: Animation, _: HTMLElement, menu: Menu): Promise<Animation> {
|
||||||
let closedX: string, openedX: string;
|
let closedX: string, openedX: string;
|
||||||
const width = menu.width + BOX_SHADOW_WIDTH;
|
const width = menu.width + BOX_SHADOW_WIDTH;
|
||||||
if (menu.isEndSide) {
|
if (menu.isEndSide) {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Animation, Menu } from '../../../interface';
|
import { Animation, Menu } from '../../../interface';
|
||||||
import baseAnimation from './base';
|
import { baseAnimation } from './base';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
@ -7,7 +7,7 @@ import baseAnimation from './base';
|
|||||||
* The content slides over to reveal the menu underneath.
|
* The content slides over to reveal the menu underneath.
|
||||||
* The menu itself also slides over to reveal its bad self.
|
* The menu itself also slides over to reveal its bad self.
|
||||||
*/
|
*/
|
||||||
export default function(Animation: Animation, _: HTMLElement, menu: Menu): Promise<Animation> {
|
export function menuPushAnimation(Animation: Animation, _: HTMLElement, menu: Menu): Promise<Animation> {
|
||||||
|
|
||||||
let contentOpenedX: string, menuClosedX: string;
|
let contentOpenedX: string, menuClosedX: string;
|
||||||
const width = menu.width;
|
const width = menu.width;
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import { Animation, Menu } from '../../../interface';
|
import { Animation, Menu } from '../../../interface';
|
||||||
import baseAnimation from './base';
|
import { baseAnimation } from './base';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @hidden
|
* @hidden
|
||||||
@ -7,7 +7,7 @@ import baseAnimation from './base';
|
|||||||
* The content slides over to reveal the menu underneath.
|
* The content slides over to reveal the menu underneath.
|
||||||
* The menu itself, which is under the content, does not move.
|
* The menu itself, which is under the content, does not move.
|
||||||
*/
|
*/
|
||||||
export default function(Animation: Animation, _: HTMLElement, menu: Menu): Promise<Animation> {
|
export function menuRevealAnimation(Animation: Animation, _: HTMLElement, menu: Menu): Promise<Animation> {
|
||||||
const openedX = (menu.width * (menu.isEndSide ? -1 : 1)) + 'px';
|
const openedX = (menu.width * (menu.isEndSide ? -1 : 1)) + 'px';
|
||||||
|
|
||||||
const contentOpen = new Animation()
|
const contentOpen = new Animation()
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
import { Component, Method, Prop } from '@stencil/core';
|
import { Component, Method, Prop } from '@stencil/core';
|
||||||
import { Animation, AnimationBuilder, Menu } from '../../interface';
|
import { Animation, AnimationBuilder, Menu } from '../../interface';
|
||||||
|
|
||||||
import MenuOverlayAnimation from './animations/overlay';
|
import { menuOverlayAnimation } from './animations/overlay';
|
||||||
import MenuPushAnimation from './animations/push';
|
import { menuPushAnimation } from './animations/push';
|
||||||
import MenuRevealAnimation from './animations/reveal';
|
import { menuRevealAnimation } from './animations/reveal';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-menu-controller'
|
tag: 'ion-menu-controller'
|
||||||
@ -16,9 +16,9 @@ export class MenuController {
|
|||||||
@Prop({ connect: 'ion-animation-controller' }) animationCtrl!: HTMLIonAnimationControllerElement;
|
@Prop({ connect: 'ion-animation-controller' }) animationCtrl!: HTMLIonAnimationControllerElement;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.registerAnimation('reveal', MenuRevealAnimation);
|
this.registerAnimation('reveal', menuRevealAnimation);
|
||||||
this.registerAnimation('push', MenuPushAnimation);
|
this.registerAnimation('push', menuPushAnimation);
|
||||||
this.registerAnimation('overlay', MenuOverlayAnimation);
|
this.registerAnimation('overlay', menuOverlayAnimation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -279,4 +279,4 @@ export class MenuController {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export { MenuOverlayAnimation, MenuPushAnimation, MenuRevealAnimation };
|
export { menuOverlayAnimation, menuPushAnimation, menuRevealAnimation };
|
||||||
|
@ -4,7 +4,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Modal Enter Animation
|
* iOS Modal Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -4,7 +4,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Modal Leave Animation
|
* iOS Modal Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* Md Modal Enter Animation
|
* Md Modal Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* Md Modal Leave Animation
|
* Md Modal Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -5,11 +5,11 @@ import { attachComponent, detachComponent } from '../../utils/framework-delegate
|
|||||||
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, present } from '../../utils/overlays';
|
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, present } from '../../utils/overlays';
|
||||||
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
||||||
|
|
||||||
import iosEnterAnimation from './animations/ios.enter';
|
import { iosEnterAnimation } from './animations/ios.enter';
|
||||||
import iosLeaveAnimation from './animations/ios.leave';
|
import { iosLeaveAnimation } from './animations/ios.leave';
|
||||||
|
|
||||||
import mdEnterAnimation from './animations/md.enter';
|
import { mdEnterAnimation } from './animations/md.enter';
|
||||||
import mdLeaveAnimation from './animations/md.leave';
|
import { mdLeaveAnimation } from './animations/md.leave';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-modal',
|
tag: 'ion-modal',
|
||||||
|
@ -4,7 +4,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Picker Enter Animation
|
* iOS Picker Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -4,7 +4,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Picker Leave Animation
|
* iOS Picker Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -4,8 +4,8 @@ import { Animation, AnimationBuilder, Config, CssClassMap, Mode, PickerButton, P
|
|||||||
import { OverlayEventDetail, OverlayInterface, dismiss, eventMethod, present } from '../../utils/overlays';
|
import { OverlayEventDetail, OverlayInterface, dismiss, eventMethod, present } from '../../utils/overlays';
|
||||||
import { getClassMap } from '../../utils/theme';
|
import { getClassMap } from '../../utils/theme';
|
||||||
|
|
||||||
import iosEnterAnimation from './animations/ios.enter';
|
import { iosEnterAnimation } from './animations/ios.enter';
|
||||||
import iosLeaveAnimation from './animations/ios.leave';
|
import { iosLeaveAnimation } from './animations/ios.leave';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-picker',
|
tag: 'ion-picker',
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Popover Enter Animation
|
* iOS Popover Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement, ev?: Event): Promise<Animation> {
|
export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement, ev?: Event): Promise<Animation> {
|
||||||
let originY = 'top';
|
let originY = 'top';
|
||||||
let originX = 'left';
|
let originX = 'left';
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Popover Leave Animation
|
* iOS Popover Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* Md Popover Enter Animation
|
* Md Popover Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement, ev?: Event): Promise<Animation> {
|
export function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement, ev?: Event): Promise<Animation> {
|
||||||
let originY = 'top';
|
let originY = 'top';
|
||||||
let originX = 'left';
|
let originX = 'left';
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* Md Popover Leave Animation
|
* Md Popover Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
export function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const backdropAnimation = new Animation();
|
const backdropAnimation = new Animation();
|
||||||
|
@ -5,11 +5,11 @@ import { attachComponent, detachComponent } from '../../utils/framework-delegate
|
|||||||
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, present } from '../../utils/overlays';
|
import { BACKDROP, OverlayEventDetail, OverlayInterface, dismiss, eventMethod, present } from '../../utils/overlays';
|
||||||
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
||||||
|
|
||||||
import iosEnterAnimation from './animations/ios.enter';
|
import { iosEnterAnimation } from './animations/ios.enter';
|
||||||
import iosLeaveAnimation from './animations/ios.leave';
|
import { iosLeaveAnimation } from './animations/ios.leave';
|
||||||
|
|
||||||
import mdEnterAnimation from './animations/md.enter';
|
import { mdEnterAnimation } from './animations/md.enter';
|
||||||
import mdLeaveAnimation from './animations/md.leave';
|
import { mdLeaveAnimation } from './animations/md.leave';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-popover',
|
tag: 'ion-popover',
|
||||||
|
@ -2,11 +2,12 @@ import { RouteChain } from './interface';
|
|||||||
import { generatePath } from './path';
|
import { generatePath } from './path';
|
||||||
|
|
||||||
export function printRoutes(routes: RouteChain[]) {
|
export function printRoutes(routes: RouteChain[]) {
|
||||||
console.debug('%c[ion-core]', 'font-weight: bold', `registered ${routes.length} routes`);
|
console.groupCollapsed(`[ion-core] registered ${routes.length} routes`);
|
||||||
for (const chain of routes) {
|
for (const chain of routes) {
|
||||||
const path: string[] = [];
|
const path: string[] = [];
|
||||||
chain.forEach(r => path.push(...r.path));
|
chain.forEach(r => path.push(...r.path));
|
||||||
const ids = chain.map(r => r.id);
|
const ids = chain.map(r => r.id);
|
||||||
console.debug(`%c ${generatePath(path)}`, 'font-weight: bold; padding-left: 20px', '=>\t', `(${ids.join(', ')})`);
|
console.debug(`%c ${generatePath(path)}`, 'font-weight: bold; padding-left: 20px', '=>\t', `(${ids.join(', ')})`);
|
||||||
}
|
}
|
||||||
|
console.groupEnd();
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Toast Enter Animation
|
* iOS Toast Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement, position: string): Promise<Animation> {
|
export function iosEnterAnimation(Animation: Animation, baseEl: HTMLElement, position: string): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const wrapperAnimation = new Animation();
|
const wrapperAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* iOS Toast Leave Animation
|
* iOS Toast Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement, position: string): Promise<Animation> {
|
export function iosLeaveAnimation(Animation: Animation, baseEl: HTMLElement, position: string): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const wrapperAnimation = new Animation();
|
const wrapperAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* MD Toast Enter Animation
|
* MD Toast Enter Animation
|
||||||
*/
|
*/
|
||||||
export default function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement, position: string): Promise<Animation> {
|
export function mdEnterAnimation(Animation: Animation, baseEl: HTMLElement, position: string): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const wrapperAnimation = new Animation();
|
const wrapperAnimation = new Animation();
|
||||||
|
@ -3,7 +3,7 @@ import { Animation } from '../../../interface';
|
|||||||
/**
|
/**
|
||||||
* md Toast Leave Animation
|
* md Toast Leave Animation
|
||||||
*/
|
*/
|
||||||
export default function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement, position: string): Promise<Animation> {
|
export function mdLeaveAnimation(Animation: Animation, baseEl: HTMLElement, position: string): Promise<Animation> {
|
||||||
const baseAnimation = new Animation();
|
const baseAnimation = new Animation();
|
||||||
|
|
||||||
const wrapperAnimation = new Animation();
|
const wrapperAnimation = new Animation();
|
||||||
|
@ -4,11 +4,11 @@ import { Animation, AnimationBuilder, Config, Mode } from '../../interface';
|
|||||||
import { OverlayEventDetail, OverlayInterface, dismiss, eventMethod, present } from '../../utils/overlays';
|
import { OverlayEventDetail, OverlayInterface, dismiss, eventMethod, present } from '../../utils/overlays';
|
||||||
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
import { createThemedClasses, getClassMap } from '../../utils/theme';
|
||||||
|
|
||||||
import iosEnterAnimation from './animations/ios.enter';
|
import { iosEnterAnimation } from './animations/ios.enter';
|
||||||
import iosLeaveAnimation from './animations/ios.leave';
|
import { iosLeaveAnimation } from './animations/ios.leave';
|
||||||
|
|
||||||
import mdEnterAnimation from './animations/md.enter';
|
import { mdEnterAnimation } from './animations/md.enter';
|
||||||
import mdLeaveAnimation from './animations/md.leave';
|
import { mdLeaveAnimation } from './animations/md.leave';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
tag: 'ion-toast',
|
tag: 'ion-toast',
|
||||||
|
@ -9,7 +9,7 @@ const TRANSLATEX = 'translateX';
|
|||||||
const CENTER = '0%';
|
const CENTER = '0%';
|
||||||
const OFF_OPACITY = 0.8;
|
const OFF_OPACITY = 0.8;
|
||||||
|
|
||||||
export default function iosTransitionAnimation(Animation: Animation, navEl: HTMLElement, opts: TransitionOptions): Promise<Animation> {
|
export function iosTransitionAnimation(Animation: Animation, navEl: HTMLElement, opts: TransitionOptions): Promise<Animation> {
|
||||||
|
|
||||||
const isRTL = document.dir === 'rtl';
|
const isRTL = document.dir === 'rtl';
|
||||||
const OFF_RIGHT = isRTL ? '-99.5%' : '99.5%';
|
const OFF_RIGHT = isRTL ? '-99.5%' : '99.5%';
|
||||||
|
@ -5,7 +5,7 @@ const TRANSLATEY = 'translateY';
|
|||||||
const OFF_BOTTOM = '40px';
|
const OFF_BOTTOM = '40px';
|
||||||
const CENTER = '0px';
|
const CENTER = '0px';
|
||||||
|
|
||||||
export default function mdTransitionAnimation(Animation: Animation, _: HTMLElement, opts: TransitionOptions): Promise<Animation> {
|
export function mdTransitionAnimation(Animation: Animation, _: HTMLElement, opts: TransitionOptions): Promise<Animation> {
|
||||||
|
|
||||||
const enteringEl = opts.enteringEl;
|
const enteringEl = opts.enteringEl;
|
||||||
const leavingEl = opts.leavingEl;
|
const leavingEl = opts.leavingEl;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { isFocused, relocateInput } from './common';
|
import { isFocused, relocateInput } from './common';
|
||||||
|
|
||||||
|
|
||||||
export default function enableHideCaretOnScroll(componentEl: HTMLElement, inputEl: HTMLInputElement, scrollEl: HTMLIonScrollElement) {
|
export function enableHideCaretOnScroll(componentEl: HTMLElement, inputEl: HTMLInputElement, scrollEl: HTMLIonScrollElement) {
|
||||||
if (!scrollEl || !inputEl) {
|
if (!scrollEl || !inputEl) {
|
||||||
return () => { return; };
|
return () => { return; };
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
|
|
||||||
const SKIP_BLURRING = ['INPUT', 'TEXTAREA', 'ION-INPUT', 'ION-TEXTAREA'];
|
const SKIP_BLURRING = ['INPUT', 'TEXTAREA', 'ION-INPUT', 'ION-TEXTAREA'];
|
||||||
|
|
||||||
export default function enableInputBlurring(doc: Document) {
|
export function enableInputBlurring(doc: Document) {
|
||||||
console.debug('Input: enableInputBlurring');
|
console.debug('Input: enableInputBlurring');
|
||||||
|
|
||||||
let focused = true;
|
let focused = true;
|
@ -3,7 +3,7 @@ import { isFocused, relocateInput } from './common';
|
|||||||
import { getScrollData } from './scroll-data';
|
import { getScrollData } from './scroll-data';
|
||||||
|
|
||||||
|
|
||||||
export default function enableScrollAssist(
|
export function enableScrollAssist(
|
||||||
componentEl: HTMLElement,
|
componentEl: HTMLElement,
|
||||||
inputEl: HTMLInputElement,
|
inputEl: HTMLInputElement,
|
||||||
contentEl: HTMLIonContentElement,
|
contentEl: HTMLIonContentElement,
|
@ -1,6 +1,6 @@
|
|||||||
const PADDING_TIMER_KEY = '$ionPaddingTimer';
|
const PADDING_TIMER_KEY = '$ionPaddingTimer';
|
||||||
|
|
||||||
export default function enableScrollPadding(doc: Document, keyboardHeight: number) {
|
export function enableScrollPadding(doc: Document, keyboardHeight: number) {
|
||||||
console.debug('Input: enableScrollPadding');
|
console.debug('Input: enableScrollPadding');
|
||||||
|
|
||||||
function onFocusin(ev: any) {
|
function onFocusin(ev: any) {
|
83
core/src/utils/input-shims/input-shims.ts
Normal file
83
core/src/utils/input-shims/input-shims.ts
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
|
||||||
|
import { Config } from '../../interface';
|
||||||
|
import { enableHideCaretOnScroll } from './hacks/hide-caret';
|
||||||
|
import { enableInputBlurring } from './hacks/input-blurring';
|
||||||
|
import { enableScrollAssist } from './hacks/scroll-assist';
|
||||||
|
import { enableScrollPadding } from './hacks/scroll-padding';
|
||||||
|
|
||||||
|
const INPUT_BLURRING = true;
|
||||||
|
const SCROLL_ASSIST = true;
|
||||||
|
const SCROLL_PADDING = true;
|
||||||
|
const HIDE_CARET = true;
|
||||||
|
|
||||||
|
export function startInputShims(
|
||||||
|
doc: Document,
|
||||||
|
config: Config,
|
||||||
|
) {
|
||||||
|
const keyboardHeight = config.getNumber('keyboardHeight', 290);
|
||||||
|
const scrollAssist = config.getBoolean('scrollAssist', true);
|
||||||
|
const hideCaret = config.getBoolean('hideCaretOnScroll', true);
|
||||||
|
const inputBlurring = config.getBoolean('inputBlurring', true);
|
||||||
|
const scrollPadding = config.getBoolean('scrollPadding', true);
|
||||||
|
|
||||||
|
const hideCaretMap = new WeakMap<HTMLElement, Function>();
|
||||||
|
const scrollAssistMap = new WeakMap<HTMLElement, Function>();
|
||||||
|
|
||||||
|
function registerInput(componentEl: HTMLElement) {
|
||||||
|
const inputEl = componentEl.querySelector('input');
|
||||||
|
const scrollEl = componentEl.closest('ion-scroll');
|
||||||
|
const contentEl = componentEl.closest('ion-content');
|
||||||
|
|
||||||
|
if (!inputEl) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (HIDE_CARET && scrollEl && hideCaret && !hideCaretMap.has(componentEl)) {
|
||||||
|
const rmFn = enableHideCaretOnScroll(componentEl, inputEl, scrollEl);
|
||||||
|
hideCaretMap.set(componentEl, rmFn);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SCROLL_ASSIST && contentEl && scrollAssist && !scrollAssistMap.has(componentEl)) {
|
||||||
|
const rmFn = enableScrollAssist(componentEl, inputEl, contentEl, keyboardHeight);
|
||||||
|
scrollAssistMap.set(componentEl, rmFn);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function unregisterInput(componentEl: HTMLElement) {
|
||||||
|
if (HIDE_CARET && hideCaret) {
|
||||||
|
const fn = hideCaretMap.get(componentEl);
|
||||||
|
fn && fn();
|
||||||
|
hideCaretMap.delete(componentEl);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SCROLL_ASSIST && scrollAssist) {
|
||||||
|
const fn = scrollAssistMap.get(componentEl);
|
||||||
|
fn && fn();
|
||||||
|
scrollAssistMap.delete(componentEl);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inputBlurring && INPUT_BLURRING) {
|
||||||
|
enableInputBlurring(doc);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scrollPadding && SCROLL_PADDING) {
|
||||||
|
enableScrollPadding(doc, keyboardHeight);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Input might be already loaded in the DOM before ion-device-hacks did.
|
||||||
|
// At this point we need to look for all the ion-inputs not registered yet
|
||||||
|
// and register them.
|
||||||
|
const inputs = Array.from(doc.querySelectorAll('ion-input'));
|
||||||
|
for (const input of inputs) {
|
||||||
|
registerInput(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
doc.body.addEventListener('ionInputDidLoad', (event) => {
|
||||||
|
registerInput(event.target as any);
|
||||||
|
});
|
||||||
|
|
||||||
|
doc.body.addEventListener('ionInputDidUnload', (event) => {
|
||||||
|
unregisterInput(event.target as any);
|
||||||
|
});
|
||||||
|
}
|
@ -1,26 +1,29 @@
|
|||||||
import { Animation, AnimationBuilder, NavDirection, NavOptions } from '../interface';
|
import { Animation, AnimationBuilder, NavDirection, NavOptions } from '../interface';
|
||||||
|
|
||||||
import iosTransitionAnimation from './animations/ios.transition';
|
const iosTransitionAnimation = () => import('./animations/ios.transition');
|
||||||
import mdTransitionAnimation from './animations/md.transition';
|
const mdTransitionAnimation = () => import('./animations/md.transition');
|
||||||
|
|
||||||
export function transition(opts: TransitionOptions): Promise<Animation|null> {
|
export async function transition(opts: TransitionOptions): Promise<Animation|null> {
|
||||||
beforeTransition(opts);
|
beforeTransition(opts);
|
||||||
|
|
||||||
const animationBuilder = getAnimationBuilder(opts);
|
const animationBuilder = await getAnimationBuilder(opts);
|
||||||
return (animationBuilder)
|
return (animationBuilder)
|
||||||
? animation(animationBuilder, opts)
|
? animation(animationBuilder, opts)
|
||||||
: noAnimation(opts); // fast path for no animation
|
: noAnimation(opts); // fast path for no animation
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAnimationBuilder(opts: TransitionOptions): AnimationBuilder | undefined {
|
async function getAnimationBuilder(opts: TransitionOptions): Promise<AnimationBuilder | undefined> {
|
||||||
if (!opts.leavingEl || opts.animated === false || opts.duration === 0) {
|
if (!opts.leavingEl || opts.animated === false || opts.duration === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (opts.animationBuilder) {
|
if (opts.animationBuilder) {
|
||||||
return opts.animationBuilder;
|
return opts.animationBuilder;
|
||||||
}
|
}
|
||||||
return opts.mode === 'ios' ? iosTransitionAnimation : mdTransitionAnimation;
|
const builder = (opts.mode === 'ios')
|
||||||
|
? (await iosTransitionAnimation()).iosTransitionAnimation
|
||||||
|
: (await mdTransitionAnimation()).mdTransitionAnimation;
|
||||||
|
|
||||||
|
return builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
function beforeTransition(opts: TransitionOptions) {
|
function beforeTransition(opts: TransitionOptions) {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
"dom",
|
"dom",
|
||||||
"es2017"
|
"es2017"
|
||||||
],
|
],
|
||||||
"module": "es2015",
|
"module": "esnext",
|
||||||
"moduleResolution": "node",
|
"moduleResolution": "node",
|
||||||
"noImplicitAny": true,
|
"noImplicitAny": true,
|
||||||
"noImplicitReturns": true,
|
"noImplicitReturns": true,
|
||||||
|
Reference in New Issue
Block a user