mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
fix(accordion): improved reliability of accordion animations (#23531)
resolves #23504
This commit is contained in:
@ -208,6 +208,7 @@ export class Accordion implements ComponentInterface {
|
||||
}
|
||||
|
||||
if (this.shouldAnimate()) {
|
||||
raf(() => {
|
||||
this.state = AccordionState.Expanding;
|
||||
|
||||
this.currentRaf = raf(async () => {
|
||||
@ -215,20 +216,12 @@ export class Accordion implements ComponentInterface {
|
||||
const waitForTransition = transitionEndAsync(contentEl, 2000);
|
||||
contentEl.style.setProperty('max-height', `${contentHeight}px`);
|
||||
|
||||
/**
|
||||
* Force a repaint. We can't use an raf
|
||||
* here as it could cause the collapse animation
|
||||
* to get out of sync with the other
|
||||
* accordion's expand animation.
|
||||
*/
|
||||
// tslint:disable-next-line
|
||||
void contentEl.offsetHeight;
|
||||
|
||||
await waitForTransition;
|
||||
|
||||
this.state = AccordionState.Expanded;
|
||||
contentEl.style.removeProperty('max-height');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.state = AccordionState.Expanded;
|
||||
}
|
||||
@ -254,16 +247,9 @@ export class Accordion implements ComponentInterface {
|
||||
const contentHeight = contentEl.offsetHeight;
|
||||
contentEl.style.setProperty('max-height', `${contentHeight}px`);
|
||||
|
||||
/**
|
||||
* Force a repaint. We can't use an raf
|
||||
* here as it could cause the collapse animation
|
||||
* to get out of sync with the other
|
||||
* accordion's expand animation.
|
||||
*/
|
||||
// tslint:disable-next-line
|
||||
void contentEl.offsetHeight;
|
||||
|
||||
raf(async () => {
|
||||
const waitForTransition = transitionEndAsync(contentEl, 2000);
|
||||
|
||||
this.state = AccordionState.Collapsing;
|
||||
|
||||
await waitForTransition;
|
||||
@ -271,6 +257,7 @@ export class Accordion implements ComponentInterface {
|
||||
this.state = AccordionState.Collapsed;
|
||||
contentEl.style.removeProperty('max-height');
|
||||
});
|
||||
});
|
||||
} else {
|
||||
this.state = AccordionState.Collapsed;
|
||||
}
|
||||
|
Reference in New Issue
Block a user