mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
perf(NoticeBar): flip
This commit is contained in:
parent
17d752f882
commit
02219625fb
@ -92,7 +92,7 @@ export default createComponent({
|
|||||||
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
|
// use double raf to ensure animation can start
|
||||||
doubleRaf(() => {
|
doubleRaf(() => {
|
||||||
wrapper.style.height = expanded ? contentHeight : 0;
|
wrapper.style.height = expanded ? contentHeight : 0;
|
||||||
});
|
});
|
||||||
|
@ -60,11 +60,15 @@ export default createComponent({
|
|||||||
this.offset = this.wrapWidth;
|
this.offset = this.wrapWidth;
|
||||||
this.duration = 0;
|
this.duration = 0;
|
||||||
|
|
||||||
setTimeout(() => {
|
// wait for Vue to render offset
|
||||||
this.offset = -this.contentWidth;
|
this.$nextTick(() => {
|
||||||
this.duration = (this.contentWidth + this.wrapWidth) / this.speed;
|
// use double raf to ensure animation can start
|
||||||
this.$emit('replay');
|
doubleRaf(() => {
|
||||||
}, 100);
|
this.offset = -this.contentWidth;
|
||||||
|
this.duration = (this.contentWidth + this.wrapWidth) / this.speed;
|
||||||
|
this.$emit('replay');
|
||||||
|
});
|
||||||
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
reset() {
|
reset() {
|
||||||
|
@ -45,7 +45,7 @@ test('replay event', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
wrapper.find('.van-notice-bar__content').trigger('transitionend');
|
wrapper.find('.van-notice-bar__content').trigger('transitionend');
|
||||||
await later(150);
|
await later(50);
|
||||||
expect(wrapper.emitted('replay')).toBeTruthy();
|
expect(wrapper.emitted('replay')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user