From cde3876fb0742cacf3e481a8eb2b487dabc8709e Mon Sep 17 00:00:00 2001 From: chenjiahan Date: Tue, 11 May 2021 15:43:53 +0800 Subject: [PATCH] fix(NoticeBar): incorrect scroll speed --- packages/notice-bar/README.md | 2 +- packages/notice-bar/index.ts | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/notice-bar/README.md b/packages/notice-bar/README.md index 3d94b5a8..51d9ac75 100644 --- a/packages/notice-bar/README.md +++ b/packages/notice-bar/README.md @@ -101,7 +101,7 @@ | background | 滚动条背景 | _string_ | `#fffbe8` | | left-icon | 左侧[图标名称](#/icon)或图片链接 | _string_ | - | | delay | 动画延迟时间 (s) | _number_ | `1` | -| speed | 滚动速率 (px/s) | _number_ | `50` | +| speed | 滚动速率 (px/s) | _number_ | `60` | | scrollable | 是否开启滚动播放,内容长度溢出时默认开启 | _boolean_ | - | | wrapable | 是否开启文本换行,只在禁用滚动时生效 | _boolean_ | `false` | | open-type | 微信开放能力 | _string_ | `navigate` | diff --git a/packages/notice-bar/index.ts b/packages/notice-bar/index.ts index 1c754a22..cf4d2854 100644 --- a/packages/notice-bar/index.ts +++ b/packages/notice-bar/index.ts @@ -26,7 +26,7 @@ VantComponent({ }, speed: { type: Number, - value: 50, + value: 60, observer: 'init', }, scrollable: null, @@ -79,7 +79,8 @@ VantComponent({ } if (scrollable || wrapRect.width < contentRect.width) { - const duration = (contentRect.width / speed) * 1000; + const duration = + ((wrapRect.width + contentRect.width) / speed) * 1000; this.wrapWidth = wrapRect.width; this.contentWidth = contentRect.width;