artsy / palette

Artsy's design system
https://palette-storybook.artsy.net/
MIT License
214 stars 45 forks source link

chore: Switch useHasEnteredViewport to use IntersectionObserver instead of unreliable logic #1339

Closed jo-rs closed 9 months ago

jo-rs commented 9 months ago

Switches the useHasEnteredViewport hook to use Force's implementation of IntersectionObserver instead of the former logic, which was causing issues on Volt V2.

Open to other suggestions.

dzucconi commented 9 months ago

We should probably do a pass on the charts sub-package at some point to modernize it.

You don't really want to interface with the IntersectionObserver outside of an effect though.

Feel free to port over our hook in Force to Palette and update callers, if you are motivated: https://github.com/artsy/force/blob/main/src/Utils/Hooks/useIntersectionObserver.ts

jo-rs commented 9 months ago

Sorry, I was frustrated when I pushed the last commit, and it was a bit of a mess. As per @dzucconi's comment, I ported over Force's hook.

artsyit commented 9 months ago

:rocket: PR was released in @artsy/palette-charts@36.2.0, @artsy/palette@37.2.0 :rocket: