mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +08:00
[bugfix] NoticeBar text disappeared when page back (#280)
* [bugfix] CouponList always show empty info * [bugfix] add click feedback of buttons in components * [Doc] add custom theme document * [new feature] Notice bar support more props * [bugfix] PullRefresh test cases * [bugfix] unused NoticeBar style * [bugfix] Swipe width calc error * [Doc] english document of all action components * [Doc] change document site path to /zanui/vant * [Doc] fix * [bugfix] uploader style error * [bugfix] tabs document demo * [new feature] Cell support vue-router target route * [bugfix] add cell test cases * update yarn.lock * [bugfix] Tabbar cann't display info when use icon slot * [Doc] update document title * [bugfix] Dialog should reset button text when showed * [new feature] CouponList add showCloseButton prop * [new feature] Swipe add 'initialSwipe' prop * [bugfix] NoticeBar text disappeared when page back
This commit is contained in:
parent
74a3eea203
commit
3f7985ed2e
@ -21,6 +21,7 @@ Vue.component(NoticeBar.name, NoticeBar);
|
|||||||
|
|
||||||
:::demo 基础用法
|
:::demo 基础用法
|
||||||
```html
|
```html
|
||||||
|
<van-notice-bar text="测试测试。"></van-notice-bar>
|
||||||
<van-notice-bar
|
<van-notice-bar
|
||||||
text="足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。"
|
text="足协杯战线连续第2年上演广州德比战,上赛季半决赛上恒大以两回合5-3的总比分淘汰富力。"
|
||||||
left-icon="//img.yzcdn.cn/public_files/2017/8/10/6af5b7168eed548100d9041f07b7c616.png"
|
left-icon="//img.yzcdn.cn/public_files/2017/8/10/6af5b7168eed548100d9041f07b7c616.png"
|
||||||
|
@ -9,7 +9,12 @@
|
|||||||
<img :src="leftIcon" />
|
<img :src="leftIcon" />
|
||||||
</div>
|
</div>
|
||||||
<div class="van-notice-bar__content-wrap" ref="contentWrap">
|
<div class="van-notice-bar__content-wrap" ref="contentWrap">
|
||||||
<div class="van-notice-bar__content" ref="content" :style="contentStyle" @transitionend="onTransitionEnd">
|
<div
|
||||||
|
ref="content"
|
||||||
|
:class="['van-notice-bar__content', animationClass]"
|
||||||
|
:style="contentStyle"
|
||||||
|
@animationend="onAnimationEnd"
|
||||||
|
>
|
||||||
<slot>{{ text }}</slot>
|
<slot>{{ text }}</slot>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@ -55,11 +60,12 @@ export default {
|
|||||||
|
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
wrapWidth: 0,
|
||||||
firstRound: true,
|
firstRound: true,
|
||||||
duration: 0,
|
duration: 0,
|
||||||
offsetWidth: 0,
|
offsetWidth: 0,
|
||||||
showNoticeBar: true,
|
showNoticeBar: true,
|
||||||
diableTransition: false
|
animationClass: ''
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -75,9 +81,9 @@ export default {
|
|||||||
},
|
},
|
||||||
contentStyle() {
|
contentStyle() {
|
||||||
return {
|
return {
|
||||||
transform: `translate3d(${-this.offsetWidth}px, 0, 0)`,
|
paddingLeft: this.firstRound ? 0 : this.wrapWidth + 'px',
|
||||||
transitionDelay: (this.firstRound ? this.delay : 0) + 's',
|
animationDelay: (this.firstRound ? this.delay : 0) + 's',
|
||||||
transitionDuration: this.duration + 's'
|
animationDuration: this.duration + 's'
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
@ -88,7 +94,8 @@ export default {
|
|||||||
if (this.scrollable && offsetWidth > wrapWidth) {
|
if (this.scrollable && offsetWidth > wrapWidth) {
|
||||||
this.wrapWidth = wrapWidth;
|
this.wrapWidth = wrapWidth;
|
||||||
this.offsetWidth = offsetWidth;
|
this.offsetWidth = offsetWidth;
|
||||||
this.duration = (offsetWidth + wrapWidth) / this.speed;
|
this.duration = offsetWidth / this.speed;
|
||||||
|
this.animationClass = 'van-notice-bar__play';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -96,17 +103,12 @@ export default {
|
|||||||
onClickIcon() {
|
onClickIcon() {
|
||||||
this.showNoticeBar = this.mode !== 'closeable';
|
this.showNoticeBar = this.mode !== 'closeable';
|
||||||
},
|
},
|
||||||
onTransitionEnd() {
|
onAnimationEnd() {
|
||||||
const { offsetWidth, wrapWidth } = this;
|
|
||||||
this.firstRound = false;
|
this.firstRound = false;
|
||||||
this.duration = 0;
|
this.$nextTick(() => {
|
||||||
this.offsetWidth = -this.wrapWidth;
|
this.duration = (this.offsetWidth + this.wrapWidth) / this.speed;
|
||||||
|
this.animationClass = 'van-notice-bar__play--infinite';
|
||||||
// wait for vue render && dom update
|
});
|
||||||
setTimeout(() => {
|
|
||||||
this.duration = (offsetWidth + 2 * wrapWidth) / this.speed;
|
|
||||||
this.offsetWidth = offsetWidth;
|
|
||||||
}, 50);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -32,7 +32,6 @@
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
font-size: 15px;
|
font-size: 15px;
|
||||||
line-height: 1;
|
line-height: 1;
|
||||||
cursor: pointer;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
&__content-wrap {
|
&__content-wrap {
|
||||||
@ -45,6 +44,24 @@
|
|||||||
&__content {
|
&__content {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
transition: all linear;
|
}
|
||||||
|
|
||||||
|
&__play {
|
||||||
|
animation: van-notice-bar-play linear both;
|
||||||
|
}
|
||||||
|
|
||||||
|
&__play--infinite {
|
||||||
|
animation: van-notice-bar-play-infinite linear infinite both;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Declare two same keyframes
|
||||||
|
* In case that some mobile browsers can continue animation when className changed
|
||||||
|
*/
|
||||||
|
@keyframes van-notice-bar-play {
|
||||||
|
to { transform: translate3d(-100%, 0, 0) }
|
||||||
|
}
|
||||||
|
@keyframes van-notice-bar-play-infinite {
|
||||||
|
to { transform: translate3d(-100%, 0, 0) }
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user