mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
chore(packages): move the packages to root
This commit is contained in:
@ -0,0 +1,18 @@
|
||||
import { Component, Method } from '@stencil/core';
|
||||
import { Animation, AnimationBuilder, AnimationController } from './animation-interface';
|
||||
import { Animator } from './animator';
|
||||
|
||||
|
||||
@Component({
|
||||
tag: 'ion-animation-controller'
|
||||
})
|
||||
export class AnimationControllerImpl implements AnimationController {
|
||||
|
||||
@Method()
|
||||
create(animationBuilder?: AnimationBuilder, baseEl?: any, opts?: any): Promise<Animation> {
|
||||
if (animationBuilder) {
|
||||
return animationBuilder(Animator as any, baseEl, opts);
|
||||
}
|
||||
return Promise.resolve(new Animator() as any);
|
||||
}
|
||||
}
|
@ -0,0 +1,84 @@
|
||||
import { ViewController } from '../..';
|
||||
|
||||
export interface AnimationController {
|
||||
create(animationBuilder?: AnimationBuilder, baseEl?: any, opts?: any): Promise<Animation>;
|
||||
}
|
||||
|
||||
export interface Animation {
|
||||
new (): any;
|
||||
parent: Animation|undefined;
|
||||
hasChildren: boolean;
|
||||
addElement(el: Node|Node[]|NodeList): Animation;
|
||||
add(childAnimation: Animation): Animation;
|
||||
duration(milliseconds: number): Animation;
|
||||
easing(name: string): Animation;
|
||||
easingReverse(name: string): Animation;
|
||||
getDuration(opts?: PlayOptions): number;
|
||||
getEasing(): string;
|
||||
from(prop: string, val: any): Animation;
|
||||
to(prop: string, val: any, clearProperyAfterTransition?: boolean): Animation;
|
||||
fromTo(prop: string, fromVal: any, toVal: any, clearProperyAfterTransition?: boolean): Animation;
|
||||
beforeAddClass(className: string): Animation;
|
||||
beforeRemoveClass(className: string): Animation;
|
||||
beforeStyles(styles: { [property: string]: any; }): Animation;
|
||||
beforeClearStyles(propertyNames: string[]): Animation;
|
||||
beforeAddRead(domReadFn: Function): Animation;
|
||||
beforeAddWrite(domWriteFn: Function): Animation;
|
||||
duringAddClass(className: string): Animation;
|
||||
afterAddClass(className: string): Animation;
|
||||
afterRemoveClass(className: string): Animation;
|
||||
afterStyles(styles: { [property: string]: any; }): Animation;
|
||||
afterClearStyles(propertyNames: string[]): Animation;
|
||||
play(opts?: PlayOptions): void;
|
||||
playSync(): void;
|
||||
playAsync(opts?: PlayOptions): Promise<Animation>;
|
||||
reverse(shouldReverse?: boolean): Animation;
|
||||
stop(stepValue?: number): void;
|
||||
progressStart(): void;
|
||||
progressStep(stepValue: number): void;
|
||||
progressEnd(shouldComplete: boolean, currentStepValue: number, dur: number): void;
|
||||
onFinish(callback: (animation?: Animation) => void, opts?: {oneTimeCallback?: boolean, clearExistingCallacks?: boolean}): Animation;
|
||||
destroy(): void;
|
||||
isRoot(): boolean;
|
||||
hasCompleted: boolean;
|
||||
}
|
||||
|
||||
|
||||
export interface AnimationBuilder {
|
||||
(Animation: Animation, baseEl?: HTMLElement, opts?: any): Promise<Animation>;
|
||||
}
|
||||
|
||||
|
||||
export interface AnimationOptions {
|
||||
animation?: string;
|
||||
duration?: number;
|
||||
easing?: string;
|
||||
direction?: string;
|
||||
isRTL?: boolean;
|
||||
ev?: any;
|
||||
enteringView: ViewController;
|
||||
leavingView: ViewController;
|
||||
nav: HTMLIonNavElement;
|
||||
}
|
||||
|
||||
export interface PlayOptions {
|
||||
duration?: number;
|
||||
promise?: boolean;
|
||||
}
|
||||
|
||||
|
||||
export interface EffectProperty {
|
||||
effectName: string;
|
||||
trans: boolean;
|
||||
wc?: string;
|
||||
to?: EffectState;
|
||||
from?: EffectState;
|
||||
[state: string]: any;
|
||||
}
|
||||
|
||||
|
||||
export interface EffectState {
|
||||
val: any;
|
||||
num: number|null;
|
||||
effectUnit: string;
|
||||
}
|
1252
core/src/components/animation-controller/animator.tsx
Normal file
1252
core/src/components/animation-controller/animator.tsx
Normal file
File diff suppressed because it is too large
Load Diff
30
core/src/components/animation-controller/constants.ts
Normal file
30
core/src/components/animation-controller/constants.ts
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
export const CSS_PROP = function(docEle: HTMLElement) {
|
||||
// transform
|
||||
const transformProp = [
|
||||
'webkitTransform',
|
||||
'-webkit-transform',
|
||||
'webkit-transform',
|
||||
'transform'
|
||||
].find(key => (docEle.style as any)[key] !== undefined) || 'transform';
|
||||
|
||||
const transitionProp = [
|
||||
'webkitTransition',
|
||||
'transition'
|
||||
].find(key => (docEle.style as any)[key] !== undefined) || 'transition';
|
||||
|
||||
// The only prefix we care about is webkit for transitions.
|
||||
const prefix = transitionProp.indexOf('webkit') > -1 ? '-webkit-' : '';
|
||||
|
||||
return {
|
||||
transitionDurationProp: prefix + 'transition-duration',
|
||||
transitionTimingFnProp: prefix + 'transition-timing-function',
|
||||
transformProp,
|
||||
transitionProp
|
||||
};
|
||||
|
||||
}(document.documentElement);
|
||||
|
||||
export const CSS_VALUE_REGEX = /(^-?\d*\.?\d*)(.*)/;
|
||||
export const DURATION_MIN = 32;
|
||||
export const TRANSITION_END_FALLBACK_PADDING_MS = 400;
|
16
core/src/components/animation-controller/readme.md
Normal file
16
core/src/components/animation-controller/readme.md
Normal file
@ -0,0 +1,16 @@
|
||||
# ion-animation-controller
|
||||
|
||||
|
||||
|
||||
<!-- Auto Generated Below -->
|
||||
|
||||
|
||||
## Methods
|
||||
|
||||
#### create()
|
||||
|
||||
|
||||
|
||||
----------------------------------------------
|
||||
|
||||
*Built with [StencilJS](https://stenciljs.com/)*
|
33
core/src/components/animation-controller/transition-end.ts
Normal file
33
core/src/components/animation-controller/transition-end.ts
Normal file
@ -0,0 +1,33 @@
|
||||
|
||||
|
||||
export function transitionEnd(el: HTMLElement, callback: {(ev?: TransitionEvent): void}) {
|
||||
let unRegTrans: Function;
|
||||
let unRegWKTrans: Function;
|
||||
const opts: any = { passive: true };
|
||||
|
||||
function unregister() {
|
||||
unRegWKTrans && unRegWKTrans();
|
||||
unRegTrans && unRegTrans();
|
||||
}
|
||||
|
||||
function onTransitionEnd(ev: TransitionEvent) {
|
||||
if (el === ev.target) {
|
||||
unregister();
|
||||
callback(ev);
|
||||
}
|
||||
}
|
||||
|
||||
if (el) {
|
||||
el.addEventListener('webkitTransitionEnd', onTransitionEnd, opts);
|
||||
unRegWKTrans = function() {
|
||||
el.removeEventListener('webkitTransitionEnd', onTransitionEnd, opts);
|
||||
};
|
||||
|
||||
el.addEventListener('transitionend', onTransitionEnd, opts);
|
||||
unRegTrans = function() {
|
||||
el.removeEventListener('transitionend', onTransitionEnd, opts);
|
||||
};
|
||||
}
|
||||
|
||||
return unregister;
|
||||
}
|
Reference in New Issue
Block a user