perf(NoticeBar): flip

This commit is contained in:
chenjiahan
2020-06-19 21:36:41 +08:00
parent 17d752f882
commit 02219625fb
3 changed files with 11 additions and 7 deletions
+9 -5
View File
@@ -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() {