[bugfix] Collapse: use double raf to ensure animation can start (#3723)

This commit is contained in:
neverland 2019-07-02 16:36:07 +08:00 committed by GitHub
parent 5b4a4cc078
commit e7e015e9a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -74,9 +74,13 @@ export default createComponent({
if (offsetHeight) { if (offsetHeight) {
const contentHeight = `${offsetHeight}px`; const contentHeight = `${offsetHeight}px`;
wrapper.style.height = expanded ? 0 : contentHeight; wrapper.style.height = expanded ? 0 : contentHeight;
// use double raf to ensure animation can start in mobile safari
raf(() => {
raf(() => { raf(() => {
wrapper.style.height = expanded ? contentHeight : 0; wrapper.style.height = expanded ? contentHeight : 0;
}); });
});
} else { } else {
this.onTransitionEnd(); this.onTransitionEnd();
} }