Skip to content

Commit ce8583e

Browse files
author
filip mertens
committed
fix scrolling
1 parent 300e3c4 commit ce8583e

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

libs/remix-ui/vertical-icons-panel/src/lib/reducers/verticalScrollReducer.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ export function verticalScrollReducer (prevState: any, actionPayload: actionType
99
const { scrollHeight, clientHeight } = actionPayload.payload
1010
let { scrollState } = actionPayload.payload
1111
if (scrollHeight > clientHeight) scrollState = true
12+
console.log(scrollHeight, clientHeight)
13+
console.log(scrollState)
1214
return { scrollHeight, clientHeight, scrollState }
1315
}
1416
return prevState

libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.tsx

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,32 @@ const RemixUiVerticalIconsPanel = ({
3030
const iconPanelRef = useRef<any>()
3131
const [activateScroll, dispatchScrollAction] = useReducer(verticalScrollReducer, initialState)
3232
const [theme, setTheme] = useState<string>('dark')
33+
34+
35+
36+
const evaluateScrollability = () => {
37+
dispatchScrollAction({
38+
type: 'resize',
39+
payload: {
40+
scrollHeight: scrollableRef.current?.scrollHeight,
41+
clientHeight: scrollableRef.current?.clientHeight,
42+
scrollState: false
43+
}
44+
})
45+
}
46+
3347
useEffect(() => {
34-
const evaluateScrollability = (evt: any) => {
35-
dispatchScrollAction({
36-
type: 'resize',
37-
payload: {
38-
scrollHeight: scrollableRef.current?.scrollHeight,
39-
clientHeight: scrollableRef.current?.clientHeight,
40-
scrollState: false
41-
}
42-
})
43-
}
44-
addEventListener('resize', evaluateScrollability)
48+
window.addEventListener('resize', evaluateScrollability)
49+
evaluateScrollability()
4550
return () => {
46-
removeEventListener('resize', evaluateScrollability)
51+
window.removeEventListener('resize', evaluateScrollability)
4752
}
48-
})
53+
}, [])
54+
55+
useEffect(() => {
56+
evaluateScrollability()
57+
},[icons, theme])
58+
4959
useEffect(() => {
5060
verticalIconsPlugin.call('theme', 'currentTheme').then((th: any) => {
5161
setTheme(th.quality)

0 commit comments

Comments
 (0)