Skip to content

Commit 54eb3fa

Browse files
committed
add cssvar
1 parent 1792d58 commit 54eb3fa

1 file changed

Lines changed: 25 additions & 31 deletions

File tree

src/ScrollBar.tsx

Lines changed: 25 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -210,44 +210,38 @@ const ScrollBar = React.forwardRef<ScrollBarRef, ScrollBarProps>((props, ref) =>
210210
const thumbStyle: React.CSSProperties = {
211211
position: 'absolute',
212212
borderRadius: 99,
213-
background: 'var(--rc-virtual-list-scrollbar-bg)',
213+
background: 'var(--rc-virtual-list-scrollbar-bg, rgba(0, 0, 0, 0.5))',
214214
cursor: 'pointer',
215215
userSelect: 'none',
216216
...propsThumbStyle,
217217
};
218218

219219
if (horizontal) {
220-
// Container
221-
containerStyle.height = 8;
222-
containerStyle.left = 0;
223-
containerStyle.right = 0;
224-
containerStyle.bottom = 0;
225-
226-
// Thumb
227-
thumbStyle.height = '100%';
228-
thumbStyle.width = spinSize;
229-
230-
if (isLTR) {
231-
thumbStyle.left = top;
232-
} else {
233-
thumbStyle.right = top;
234-
}
220+
Object.assign(containerStyle, {
221+
height: 8,
222+
left: 0,
223+
right: 0,
224+
bottom: 0,
225+
});
226+
227+
Object.assign(thumbStyle, {
228+
height: '100%',
229+
width: spinSize,
230+
[isLTR ? 'left' : 'right']: top,
231+
});
235232
} else {
236-
// Container
237-
containerStyle.width = 8;
238-
containerStyle.top = 0;
239-
containerStyle.bottom = 0;
240-
241-
if (isLTR) {
242-
containerStyle.right = 0;
243-
} else {
244-
containerStyle.left = 0;
245-
}
246-
247-
// Thumb
248-
thumbStyle.width = '100%';
249-
thumbStyle.height = spinSize;
250-
thumbStyle.top = top;
233+
Object.assign(containerStyle, {
234+
width: 8,
235+
top: 0,
236+
bottom: 0,
237+
[isLTR ? 'right' : 'left']: 0,
238+
});
239+
240+
Object.assign(thumbStyle, {
241+
width: '100%',
242+
height: spinSize,
243+
top,
244+
});
251245
}
252246

253247
return (

0 commit comments

Comments
 (0)