未验证 提交 ea66e468 编写于 作者: V vickyYe 提交者: GitHub

fix: noticebar纵向滚动渲染慢问题修复,设置高度小于默认值时动效失效问题修复 (#528)

上级 c42beb08
......@@ -85,6 +85,7 @@ const NoticeBarDemo = () => {
list={horseLamp1}
speed={10}
standTime={1000}
height={30}
onClick={(e) => {
go(e.target.innerHTML)
}}
......
......@@ -116,7 +116,6 @@
padding: 0;
display: block;
flex: 1;
.horseLamp_list_item {
display: flex;
align-items: center;
......
......@@ -201,19 +201,24 @@ export const NoticeBar: FunctionComponent<
*/
const startRollEasy = () => {
showhorseLamp()
const timerCurr = setInterval(
showhorseLamp,
~~(height / speed / 4) * 1000 + Number(standTime)
)
const time =
height / speed / 4 < 1
? Number((height / speed / 4).toFixed(1)) * 1000
: ~~(height / speed / 4) * 1000
const timerCurr = setInterval(showhorseLamp, time + Number(standTime))
SetTimer(timerCurr)
}
const showhorseLamp = () => {
SetAnimate(true)
const time =
height / speed / 4 < 1
? Number((height / speed / 4).toFixed(1)) * 1000
: ~~(height / speed / 4) * 1000
setTimeout(() => {
scrollList.current.push(scrollList.current[0])
scrollList.current.shift()
SetAnimate(false)
}, ~~(height / speed / 4) * 1000)
}, time)
}
const startRoll = () => {
......@@ -283,11 +288,16 @@ export const NoticeBar: FunctionComponent<
height: direction === 'vertical' ? `${height}px` : '',
}
const duringTime = ~~(height / speed / 4)
const duringTime =
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 = {
transform: complexAm ? `translateY(${distance}px)` : '',
transition: animate
? `all ${duringTime === 0 ? ~~(height / speed) : duringTime}s`
? `all ${duringTime === 0 ? noDuring : duringTime}s`
: '',
marginTop: animate ? `-${height}px` : '',
}
......
......@@ -199,19 +199,24 @@ export const NoticeBar: FunctionComponent<
*/
const startRollEasy = () => {
showhorseLamp()
const timerCurr = setInterval(
showhorseLamp,
~~(height / speed / 4) * 1000 + Number(standTime)
)
const time =
height / speed / 4 < 1
? Number((height / speed / 4).toFixed(1)) * 1000
: ~~(height / speed / 4) * 1000
const timerCurr = setInterval(showhorseLamp, time + Number(standTime))
SetTimer(timerCurr)
}
const showhorseLamp = () => {
SetAnimate(true)
const time =
height / speed / 4 < 1
? Number((height / speed / 4).toFixed(1)) * 1000
: ~~(height / speed / 4) * 1000
setTimeout(() => {
scrollList.current.push(scrollList.current[0])
scrollList.current.shift()
SetAnimate(false)
}, ~~(height / speed / 4) * 1000)
}, time)
}
const startRoll = () => {
......@@ -281,11 +286,16 @@ export const NoticeBar: FunctionComponent<
height: direction === 'vertical' ? `${height}px` : '',
}
const duringTime = ~~(height / speed / 4)
const duringTime =
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 = {
transform: complexAm ? `translateY(${distance}px)` : '',
transition: animate
? `all ${duringTime === 0 ? ~~(height / speed) : duringTime}s`
? `all ${duringTime === 0 ? noDuring : duringTime}s`
: '',
marginTop: animate ? `-${height}px` : '',
}
......@@ -343,9 +353,7 @@ export const NoticeBar: FunctionComponent<
) : null}
</div>
) : null}
{showNoticeBar &&
scrollList.current.length > 0 &&
direction === 'vertical' ? (
{showNoticeBar && direction === 'vertical' ? (
<div
className="nut-noticebar-vertical"
style={barStyle}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册