mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
feat(accordion): add accordion and accordion-group components (#22865)
resolves #17094
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
import { writeTask } from '@stencil/core';
|
||||
|
||||
import { createAnimation } from '../../utils/animation/animation';
|
||||
import { clamp, componentOnReady } from '../../utils/helpers';
|
||||
import { clamp, componentOnReady, transitionEndAsync } from '../../utils/helpers';
|
||||
import { isPlatform } from '../../utils/platform';
|
||||
|
||||
// MD Native Refresher
|
||||
@ -198,46 +198,3 @@ export const shouldUseNativeRefresher = async (referenceEl: HTMLIonRefresherElem
|
||||
|
||||
);
|
||||
};
|
||||
|
||||
export const transitionEndAsync = (el: HTMLElement | null, expectedDuration = 0) => {
|
||||
return new Promise(resolve => {
|
||||
transitionEnd(el, expectedDuration, resolve);
|
||||
});
|
||||
};
|
||||
|
||||
const transitionEnd = (el: HTMLElement | null, expectedDuration = 0, callback: (ev?: TransitionEvent) => void) => {
|
||||
let unRegTrans: (() => void) | undefined;
|
||||
let animationTimeout: any;
|
||||
const opts: any = { passive: true };
|
||||
const ANIMATION_FALLBACK_TIMEOUT = 500;
|
||||
|
||||
const unregister = () => {
|
||||
if (unRegTrans) {
|
||||
unRegTrans();
|
||||
}
|
||||
};
|
||||
|
||||
const onTransitionEnd = (ev?: Event) => {
|
||||
if (ev === undefined || el === ev.target) {
|
||||
unregister();
|
||||
callback(ev as TransitionEvent);
|
||||
}
|
||||
};
|
||||
|
||||
if (el) {
|
||||
el.addEventListener('webkitTransitionEnd', onTransitionEnd, opts);
|
||||
el.addEventListener('transitionend', onTransitionEnd, opts);
|
||||
animationTimeout = setTimeout(onTransitionEnd, expectedDuration + ANIMATION_FALLBACK_TIMEOUT);
|
||||
|
||||
unRegTrans = () => {
|
||||
if (animationTimeout) {
|
||||
clearTimeout(animationTimeout);
|
||||
animationTimeout = undefined;
|
||||
}
|
||||
el.removeEventListener('webkitTransitionEnd', onTransitionEnd, opts);
|
||||
el.removeEventListener('transitionend', onTransitionEnd, opts);
|
||||
};
|
||||
}
|
||||
|
||||
return unregister;
|
||||
};
|
||||
|
Reference in New Issue
Block a user