mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-05-26 00:09:15 +08:00
feat(Notice): bar reset variable and scrollable method extraction (#6069)
This commit is contained in:
parent
9984f6de79
commit
84369690c0
@ -39,21 +39,7 @@ export default createComponent({
|
|||||||
watch: {
|
watch: {
|
||||||
text: {
|
text: {
|
||||||
handler() {
|
handler() {
|
||||||
this.$nextTick(() => {
|
this.start();
|
||||||
const { wrap, content } = this.$refs;
|
|
||||||
if (!wrap || !content) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
const wrapWidth = wrap.getBoundingClientRect().width;
|
|
||||||
const offsetWidth = content.getBoundingClientRect().width;
|
|
||||||
if (this.scrollable && offsetWidth > wrapWidth) {
|
|
||||||
this.wrapWidth = wrapWidth;
|
|
||||||
this.offsetWidth = offsetWidth;
|
|
||||||
this.duration = offsetWidth / this.speed;
|
|
||||||
this.animationClass = bem('play');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
},
|
},
|
||||||
immediate: true,
|
immediate: true,
|
||||||
},
|
},
|
||||||
@ -75,6 +61,33 @@ export default createComponent({
|
|||||||
this.$emit('replay');
|
this.$emit('replay');
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
|
reset() {
|
||||||
|
this.wrapWidth = 0;
|
||||||
|
this.offsetWidth = 0;
|
||||||
|
this.animationClass = '';
|
||||||
|
this.duration = 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
start(){
|
||||||
|
this.$nextTick(() => {
|
||||||
|
const { wrap, content } = this.$refs;
|
||||||
|
if (!wrap || !content) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const wrapWidth = wrap.getBoundingClientRect().width;
|
||||||
|
const offsetWidth = content.getBoundingClientRect().width;
|
||||||
|
if (this.scrollable && offsetWidth > wrapWidth) {
|
||||||
|
this.wrapWidth = wrapWidth;
|
||||||
|
this.offsetWidth = offsetWidth;
|
||||||
|
this.duration = offsetWidth / this.speed;
|
||||||
|
this.animationClass = bem('play');
|
||||||
|
} else {
|
||||||
|
this.reset();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user