Skip to content

Commit

Permalink
fix: noticebar 修复小程序多行展示问题 (#1107)
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaoyatong authored Jun 9, 2023
1 parent 89b953e commit 95ed2f3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 27 deletions.
3 changes: 0 additions & 3 deletions src/packages/noticebar/noticebar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
}
}

// 只跑一次
.play {
animation: nut-notice-bar-play linear both running;
}
Expand All @@ -93,14 +92,12 @@
}
}

// 垂直方向的滚动
@keyframes nut-notice-bar-play-vertical {
to {
transform: translateY($noticebar-height);
}
}

// 纵向
.nut-noticebar-vertical {
position: relative;
display: flex;
Expand Down
3 changes: 1 addition & 2 deletions src/packages/noticebar/noticebar.taro.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -425,9 +425,8 @@ export const NoticeBar: FunctionComponent<
'nut-noticebar-page': true,
withicon: closeable,
close: closeable,
wrap,
wrapable: wrap,
})

useEffect(() => {
return () => {
stopAutoPlay()
Expand Down
38 changes: 16 additions & 22 deletions src/packages/noticebar/noticebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -253,10 +253,8 @@ export const NoticeBar: FunctionComponent<
height / speed / 4 < 1
? Number((height / speed / 4).toFixed(1))
: ~~(height / speed / 4)

const noDuring =
height / speed < 1 ? (height / speed).toFixed(1) : ~~(height / speed)

const horseLampStyle = {
transition: animate
? `all ${duringTime === 0 ? noDuring : duringTime}s`
Expand Down Expand Up @@ -359,7 +357,6 @@ export const NoticeBar: FunctionComponent<

const getStyle = (moveOffset = offset) => {
const target = innerRef.current

let _offset = 0
// 容器高度-元素高度
const val = rect.height - height
Expand Down Expand Up @@ -418,7 +415,6 @@ export const NoticeBar: FunctionComponent<
}
}

// const b = bem('noticebar')
const noticebarClass = classNames({
'nut-noticebar-page': true,
withicon: closeable,
Expand Down Expand Up @@ -466,24 +462,22 @@ export const NoticeBar: FunctionComponent<
>
{leftIcon ? <div className="left-icon">{leftIcon}</div> : null}
{children ? (
<>
<div className="nut-noticebar__inner" ref={innerRef}>
{scrollList.current.map((item: string, index: number) => {
return (
<div
className="scroll-inner "
style={itemStyle(index)}
key={index}
onClick={(e) => {
handleItemClick(e, item)
}}
>
{item}
</div>
)
})}
</div>
</>
<div className="nut-noticebar__inner" ref={innerRef}>
{scrollList.current.map((item: string, index: number) => {
return (
<div
className="scroll-inner "
style={itemStyle(index)}
key={index}
onClick={(e) => {
handleItemClick(e, item)
}}
>
{item}
</div>
)
})}
</div>
) : (
<div className="horseLamp_list" style={horseLampStyle}>
{scrollList.current.map((item: string, index: number) => {
Expand Down

0 comments on commit 95ed2f3

Please sign in to comment.