fix(NoticeBar): incorrect scroll speed

This commit is contained in:
chenjiahan 2021-05-11 15:43:53 +08:00
parent c0db43fc88
commit cde3876fb0
2 changed files with 4 additions and 3 deletions

View File

@ -101,7 +101,7 @@
| background | 滚动条背景 | _string_ | `#fffbe8` | | background | 滚动条背景 | _string_ | `#fffbe8` |
| left-icon | 左侧[图标名称](#/icon)或图片链接 | _string_ | - | | left-icon | 左侧[图标名称](#/icon)或图片链接 | _string_ | - |
| delay | 动画延迟时间 (s) | _number_ | `1` | | delay | 动画延迟时间 (s) | _number_ | `1` |
| speed | 滚动速率 (px/s) | _number_ | `50` | | speed | 滚动速率 (px/s) | _number_ | `60` |
| scrollable | 是否开启滚动播放,内容长度溢出时默认开启 | _boolean_ | - | | scrollable | 是否开启滚动播放,内容长度溢出时默认开启 | _boolean_ | - |
| wrapable | 是否开启文本换行,只在禁用滚动时生效 | _boolean_ | `false` | | wrapable | 是否开启文本换行,只在禁用滚动时生效 | _boolean_ | `false` |
| open-type | 微信开放能力 | _string_ | `navigate` | | open-type | 微信开放能力 | _string_ | `navigate` |

View File

@ -26,7 +26,7 @@ VantComponent({
}, },
speed: { speed: {
type: Number, type: Number,
value: 50, value: 60,
observer: 'init', observer: 'init',
}, },
scrollable: null, scrollable: null,
@ -79,7 +79,8 @@ VantComponent({
} }
if (scrollable || wrapRect.width < contentRect.width) { 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.wrapWidth = wrapRect.width;
this.contentWidth = contentRect.width; this.contentWidth = contentRect.width;