Reputation: 53
I need to change position of element if it out of viewport. By default it's absolute, but when i scrolling (horizontal) parent div and this element is hiding i want to make it fixed. How to make it work? I heard about Observer but it's make my component flickering.
const [position, setPosition] = useState('absolute')
const deadlineRef = useRef(null)
return (
<Tooltip
label={<TooltipLabel data={operationData} />}
placement='top'
hasArrow
>
<VStack
position={position}
mt='33px'
gap={0}
left={
view === 'DAY'
? `calc(${x * 100}% + 50px)`
: `calc(${x * 100}%)`
}
ref={deadlineRef}
>
<Icon
w='12px'
h='12px'
as={RiSquareFill}
/>
</VStack>
</Tooltip>
)
Upvotes: 0
Views: 13