fix: Safari Badge scroll number missing

This commit is contained in:
二货机器人 2024-11-12 22:01:50 +08:00
parent 776cd5f5eb
commit 28b11e9173

View File

@ -79,23 +79,29 @@ const SingleNumber: React.FC<Readonly<SingleNumberProps>> = (props) => {
unitNumberList.push(index); unitNumberList.push(index);
} }
const unit = prevCount < count ? 1 : -1;
// Fill with number unit nodes // Fill with number unit nodes
const prevIndex = unitNumberList.findIndex((n) => n % 10 === prevValue); const prevIndex = unitNumberList.findIndex((n) => n % 10 === prevValue);
unitNodes = unitNumberList.map((n, index) => {
// Cut list
const cutUnitNumberList =
unit < 0 ? unitNumberList.slice(0, prevIndex + 1) : unitNumberList.slice(prevIndex);
unitNodes = cutUnitNumberList.map((n, index) => {
const singleUnit = n % 10; const singleUnit = n % 10;
return ( return (
<UnitNumber <UnitNumber
{...props} {...props}
key={n} key={n}
value={singleUnit} value={singleUnit}
offset={index - prevIndex} offset={unit < 0 ? index - prevIndex : index}
current={index === prevIndex} current={index === prevIndex}
/> />
); );
}); });
// Calculate container offset value // Calculate container offset value
const unit = prevCount < count ? 1 : -1;
offsetStyle = { offsetStyle = {
transform: `translateY(${-getOffset(prevValue, value, unit)}00%)`, transform: `translateY(${-getOffset(prevValue, value, unit)}00%)`,
}; };