Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

useIntersectionObserver return previous entry as well #395

Open
devth opened this issue Nov 14, 2023 · 3 comments · Fixed by #464 · May be fixed by EchoSkorJjj/UI#255
Open

useIntersectionObserver return previous entry as well #395

devth opened this issue Nov 14, 2023 · 3 comments · Fixed by #464 · May be fixed by EchoSkorJjj/UI#255
Labels
enhancement Improvements V3 Something introduces breaking changes.

Comments

@devth
Copy link

devth commented Nov 14, 2023

It seems like it'd be generally useful to have the previous entry (or list of prev entries) returned from the hook. That way client code could compare timings, e.g.

const [ entry, prevEntry ] = useIntersectionObserver(ref, {})
const timeOnScreen = prevEntry ?? entry.time - prevEntry.time

or all previous entries like:

const { entry, previousEntries } = useIntersectionObserver(ref, {})
// ... do fancy comparisons
@juliencrn
Copy link
Owner

Hi, thanks for the feedback!
I've pushed a PR that should fix it, feel free to give a code review on it.
See #464

@devth
Copy link
Author

devth commented Feb 2, 2024

Amazing, thanks @juliencrn. I'll check it out!

@devth
Copy link
Author

devth commented Feb 5, 2024

Hey @juliencrn, I might have missed it but I don't see a way to get the previous entry with the new code.

@juliencrn juliencrn reopened this Feb 6, 2024
@juliencrn juliencrn added the V3 Something introduces breaking changes. label Feb 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvements V3 Something introduces breaking changes.
Projects
None yet
2 participants