mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 18:36:51 +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() {
|
mounted() {
|
||||||
const offsetWidth = this.$refs.content.getBoundingClientRect().width;
|
this.initAnimation();
|
||||||
const wrapWidth = this.$refs.contentWrap.getBoundingClientRect().width;
|
},
|
||||||
if (this.scrollable && offsetWidth > wrapWidth) {
|
|
||||||
this.wrapWidth = wrapWidth;
|
watch: {
|
||||||
this.offsetWidth = offsetWidth;
|
text: function() {
|
||||||
this.duration = offsetWidth / this.speed;
|
this.$nextTick(this.initAnimation);
|
||||||
this.animationClass = 'van-notice-bar__play';
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -102,6 +101,16 @@ export default create({
|
|||||||
this.duration = (this.offsetWidth + this.wrapWidth) / this.speed;
|
this.duration = (this.offsetWidth + this.wrapWidth) / this.speed;
|
||||||
this.animationClass = 'van-notice-bar__play--infinite';
|
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