mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-05-22 06:31:46 +08:00
fix(notice-bar): adjust scrollable behavior (#4201)
This commit is contained in:
parent
62f7d2b65e
commit
44da05bec4
@ -102,7 +102,7 @@
|
|||||||
| 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_ | `50` |
|
||||||
| scrollable | 是否开启滚动播放,内容长度溢出时默认开启 | _boolean_ | `true` |
|
| scrollable | 是否开启滚动播放,内容长度溢出时默认开启 | _boolean_ | - |
|
||||||
| wrapable | 是否开启文本换行,只在禁用滚动时生效 | _boolean_ | `false` |
|
| wrapable | 是否开启文本换行,只在禁用滚动时生效 | _boolean_ | `false` |
|
||||||
| open-type | 微信开放能力 | _string_ | `navigate` |
|
| open-type | 微信开放能力 | _string_ | `navigate` |
|
||||||
|
|
||||||
|
@ -29,10 +29,7 @@ VantComponent({
|
|||||||
value: 50,
|
value: 50,
|
||||||
observer: 'init',
|
observer: 'init',
|
||||||
},
|
},
|
||||||
scrollable: {
|
scrollable: null,
|
||||||
type: Boolean,
|
|
||||||
value: true,
|
|
||||||
},
|
|
||||||
leftIcon: {
|
leftIcon: {
|
||||||
type: String,
|
type: String,
|
||||||
value: '',
|
value: '',
|
||||||
@ -70,17 +67,17 @@ VantComponent({
|
|||||||
getRect(this, '.van-notice-bar__wrap'),
|
getRect(this, '.van-notice-bar__wrap'),
|
||||||
]).then((rects) => {
|
]).then((rects) => {
|
||||||
const [contentRect, wrapRect] = rects;
|
const [contentRect, wrapRect] = rects;
|
||||||
|
const { speed, scrollable, delay } = this.data;
|
||||||
if (
|
if (
|
||||||
contentRect == null ||
|
contentRect == null ||
|
||||||
wrapRect == null ||
|
wrapRect == null ||
|
||||||
!contentRect.width ||
|
!contentRect.width ||
|
||||||
!wrapRect.width
|
!wrapRect.width ||
|
||||||
|
scrollable === false
|
||||||
) {
|
) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const { speed, scrollable, delay } = this.data;
|
|
||||||
|
|
||||||
if (scrollable || wrapRect.width < contentRect.width) {
|
if (scrollable || wrapRect.width < contentRect.width) {
|
||||||
const duration = (contentRect.width / speed) * 1000;
|
const duration = (contentRect.width / speed) * 1000;
|
||||||
|
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
<slot wx:else name="left-icon" />
|
<slot wx:else name="left-icon" />
|
||||||
|
|
||||||
<view class="van-notice-bar__wrap">
|
<view class="van-notice-bar__wrap">
|
||||||
<view class="van-notice-bar__content {{ !scrollable && !wrapable ? 'van-ellipsis' : '' }}" animation="{{ animationData }}">
|
<view class="van-notice-bar__content {{ scrollable === false && !wrapable ? 'van-ellipsis' : '' }}" animation="{{ animationData }}">
|
||||||
{{ text }}
|
{{ text }}
|
||||||
<slot wx:if="{{ !text }}"></slot>
|
<slot wx:if="{{ !text }}"></slot>
|
||||||
</view>
|
</view>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user