fix scrolling

pull/5370/head
filip mertens 3 years ago
parent 79fc093bc8
commit 3f529aa6cf
  1. 2
      libs/remix-ui/vertical-icons-panel/src/lib/reducers/verticalScrollReducer.ts
  2. 20
      libs/remix-ui/vertical-icons-panel/src/lib/remix-ui-vertical-icons-panel.tsx

@ -9,6 +9,8 @@ export function verticalScrollReducer (prevState: any, actionPayload: actionType
const { scrollHeight, clientHeight } = actionPayload.payload
let { scrollState } = actionPayload.payload
if (scrollHeight > clientHeight) scrollState = true
console.log(scrollHeight, clientHeight)
console.log(scrollState)
return { scrollHeight, clientHeight, scrollState }
}
return prevState

@ -30,8 +30,10 @@ const RemixUiVerticalIconsPanel = ({
const iconPanelRef = useRef<any>()
const [activateScroll, dispatchScrollAction] = useReducer(verticalScrollReducer, initialState)
const [theme, setTheme] = useState<string>('dark')
useEffect(() => {
const evaluateScrollability = (evt: any) => {
const evaluateScrollability = () => {
dispatchScrollAction({
type: 'resize',
payload: {
@ -41,11 +43,19 @@ const RemixUiVerticalIconsPanel = ({
}
})
}
addEventListener('resize', evaluateScrollability)
useEffect(() => {
window.addEventListener('resize', evaluateScrollability)
evaluateScrollability()
return () => {
removeEventListener('resize', evaluateScrollability)
window.removeEventListener('resize', evaluateScrollability)
}
})
}, [])
useEffect(() => {
evaluateScrollability()
},[icons, theme])
useEffect(() => {
verticalIconsPlugin.call('theme', 'currentTheme').then((th: any) => {
setTheme(th.quality)

Loading…
Cancel
Save