diff --git a/src/collapse-item/index.js b/src/collapse-item/index.js index d70bf0b01..25826cde8 100644 --- a/src/collapse-item/index.js +++ b/src/collapse-item/index.js @@ -92,7 +92,7 @@ export default createComponent({ const contentHeight = `${offsetHeight}px`; wrapper.style.height = expanded ? 0 : contentHeight; - // use double raf to ensure animation can start in mobile safari + // use double raf to ensure animation can start doubleRaf(() => { wrapper.style.height = expanded ? contentHeight : 0; }); diff --git a/src/notice-bar/index.js b/src/notice-bar/index.js index 49d57c1c7..83db62c64 100644 --- a/src/notice-bar/index.js +++ b/src/notice-bar/index.js @@ -60,11 +60,15 @@ export default createComponent({ this.offset = this.wrapWidth; this.duration = 0; - setTimeout(() => { - this.offset = -this.contentWidth; - this.duration = (this.contentWidth + this.wrapWidth) / this.speed; - this.$emit('replay'); - }, 100); + // wait for Vue to render offset + this.$nextTick(() => { + // use double raf to ensure animation can start + doubleRaf(() => { + this.offset = -this.contentWidth; + this.duration = (this.contentWidth + this.wrapWidth) / this.speed; + this.$emit('replay'); + }); + }); }, reset() { diff --git a/src/notice-bar/test/index.spec.js b/src/notice-bar/test/index.spec.js index 68d0b4c4d..c86bebf70 100644 --- a/src/notice-bar/test/index.spec.js +++ b/src/notice-bar/test/index.spec.js @@ -45,7 +45,7 @@ test('replay event', async () => { }); wrapper.find('.van-notice-bar__content').trigger('transitionend'); - await later(150); + await later(50); expect(wrapper.emitted('replay')).toBeTruthy(); });