feat(accordion): add accordion and accordion-group components (#22865)

resolves #17094
This commit is contained in:
Liam DeBeasi
2021-03-24 09:17:54 -04:00
committed by GitHub
parent 2c53363901
commit 073883a098
40 changed files with 4977 additions and 49 deletions

View File

@ -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;
};