Skip to content

Commit

Permalink
don't clear an existing src
Browse files Browse the repository at this point in the history
  • Loading branch information
giannif committed Jan 30, 2025
1 parent 6a36e8f commit 1d7b7bd
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/react-components/src/components/gif.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -230,8 +230,10 @@ const Gif = ({
useEffect(() => {
showGifObserver.current = new IntersectionObserver(([entry]: IntersectionObserverEntry[]) => {
const { isIntersecting } = entry
// show the gif if the container is on the screen
setShouldShowMedia(isIntersecting)
// show the gif if the container is on the screen, and we haven't show it yet
if (image.current?.src === placeholder) {
setShouldShowMedia(isIntersecting)
}
// remove the fullGifObserver if we go off the screen
// we may have already disconnected if the hasFiredSeen happened
if (!isIntersecting && fullGifObserver.current) {
Expand Down

0 comments on commit 1d7b7bd

Please sign in to comment.