Skip to content

Commit

Permalink
fix: bug in arrowscroll causing it to sometimes show/hide at the wron…
Browse files Browse the repository at this point in the history
…g times (#615)
  • Loading branch information
jsladerman authored Jun 25, 2024
1 parent 693d688 commit 5a3ef1e
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/components/ArrowScroll.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import {
Children,
type ComponentProps,
cloneElement,
useEffect,
useRef,
useState,
} from 'react'
import styled from 'styled-components'

import useResizeObserver from '../hooks/useResizeObserver'
import { ArrowLeftIcon, ArrowRightIcon } from '../icons'

const ComponentWrapperSC = styled.div({
Expand Down Expand Up @@ -37,7 +37,9 @@ const ArrowWrapperSC = styled.div<{
transition: 'opacity .2s ease',
background: `linear-gradient(${
$direction === 'left' ? 'to left' : 'to right'
}, transparent 0%, #303540 70%, #303540 100%)`,
}, transparent 0%, ${theme.colors['fill-one-selected']} 70%, ${
theme.colors['fill-one-selected']
} 100%)`,
...($direction === 'left' ? { left: 0 } : { right: 0 }),
'&.visible': {
cursor: 'pointer',
Expand Down Expand Up @@ -95,12 +97,7 @@ function ArrowScroll({ children, ...props }: { children?: any }) {
}
}

useEffect(() => {
checkScroll()
window.addEventListener('resize', checkScroll)

return () => window.removeEventListener('resize', checkScroll)
}, [])
useResizeObserver(containerRef, checkScroll)

return (
<ComponentWrapperSC {...props}>
Expand Down

0 comments on commit 5a3ef1e

Please sign in to comment.