mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
[bug fix] NoticeBar: 属性text为动态数据且使用:text方式使用时,添加自动滚动 (#515)
This commit is contained in:
parent
7a86fb69bb
commit
beee252205
@ -82,13 +82,12 @@ export default create({
|
||||
},
|
||||
|
||||
mounted() {
|
||||
const offsetWidth = this.$refs.content.getBoundingClientRect().width;
|
||||
const wrapWidth = this.$refs.contentWrap.getBoundingClientRect().width;
|
||||
if (this.scrollable && offsetWidth > wrapWidth) {
|
||||
this.wrapWidth = wrapWidth;
|
||||
this.offsetWidth = offsetWidth;
|
||||
this.duration = offsetWidth / this.speed;
|
||||
this.animationClass = 'van-notice-bar__play';
|
||||
this.initAnimation();
|
||||
},
|
||||
|
||||
watch: {
|
||||
text: function() {
|
||||
this.$nextTick(this.initAnimation);
|
||||
}
|
||||
},
|
||||
|
||||
@ -102,6 +101,16 @@ export default create({
|
||||
this.duration = (this.offsetWidth + this.wrapWidth) / this.speed;
|
||||
this.animationClass = 'van-notice-bar__play--infinite';
|
||||
});
|
||||
},
|
||||
initAnimation() {
|
||||
const offsetWidth = this.$refs.content.getBoundingClientRect().width;
|
||||
const wrapWidth = this.$refs.contentWrap.getBoundingClientRect().width;
|
||||
if (this.scrollable && offsetWidth > wrapWidth) {
|
||||
this.wrapWidth = wrapWidth;
|
||||
this.offsetWidth = offsetWidth;
|
||||
this.duration = offsetWidth / this.speed;
|
||||
this.animationClass = 'van-notice-bar__play';
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user