+
+
+
![]()
+
-
+
@@ -23,6 +31,9 @@ export default {
props: {
text: String,
+ leftIcon: String,
+ color: String,
+ background: String,
mode: {
type: String,
default: '',
@@ -38,12 +49,13 @@ export default {
},
speed: {
type: Number,
- default: 40
+ default: 50
}
},
data() {
return {
+ firstRound: true,
duration: 0,
offsetWidth: 0,
showNoticeBar: true,
@@ -55,12 +67,17 @@ export default {
iconName() {
return this.mode === 'closeable' ? 'close' : this.mode === 'link' ? 'arrow' : '';
},
+ barStyle() {
+ return {
+ color: this.color,
+ background: this.background
+ };
+ },
contentStyle() {
return {
transform: `translate3d(${-this.offsetWidth}px, 0, 0)`,
- transitionDelay: this.delay + 's',
- transitionDuration: this.duration + 's',
- transitionProperty: this.diableTransition ? 'none' : 'all'
+ transitionDelay: (this.firstRound ? this.delay : 0) + 's',
+ transitionDuration: this.duration + 's'
};
}
},
@@ -69,6 +86,7 @@ export default {
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 + wrapWidth) / this.speed;
}
@@ -79,12 +97,14 @@ export default {
this.showNoticeBar = this.mode !== 'closeable';
},
onTransitionEnd() {
- const { offsetWidth } = this;
- this.diableTransition = true;
- this.offsetWidth = 0;
+ const { offsetWidth, wrapWidth } = this;
+ this.firstRound = false;
+ this.duration = 0;
+ this.offsetWidth = -this.wrapWidth;
+ // wait for vue render && dom update
setTimeout(() => {
- this.diableTransition = false;
+ this.duration = (offsetWidth + 2 * wrapWidth) / this.speed;
this.offsetWidth = offsetWidth;
}, 50);
}
diff --git a/packages/pull-refresh/index.vue b/packages/pull-refresh/index.vue
index 8840e8a66..2cba3db7d 100644
--- a/packages/pull-refresh/index.vue
+++ b/packages/pull-refresh/index.vue
@@ -28,7 +28,7 @@