stratiformltd / react-loadable-visibility

A wrapper around react-loadable and @loadable/component to load elements once they are visible on the page.
BSD 3-Clause "New" or "Revised" License
1.01k stars 31 forks source link

Enable IntersectionObserver options #16

Open TheodorTomas opened 5 years ago

TheodorTomas commented 5 years ago

Do you want to request a feature or report a bug? feature

What is the current behaviour?

Uses default intersection options.

Desired behaviour

It would be a nice feature to be able to send down IntersectionObserver options, in particular the rootMargin option. This would allow for better UX when loading components lazily.

I would be happy to contribute to this feature if this is something you would like to add to the library.

tazsingh commented 5 years ago

I like it!

I am currently traveling and away from my computer until December. Happy to review a PR but can’t work on building the feature itself until I return.

Thanks for the idea 👍🏽

Sent from my iPhone

On Oct 31, 2018, at 7:05 PM, Theodór Tómas notifications@github.com wrote:

Do you want to request a feature or report a bug? feature

What is the current behaviour?

Uses default intersection options.

Desired behaviour

It would be a nice feature to be able to send down IntersectionObserver options, in particular the rootMargin option. This would allow for better UX when loading components lazily.

I would be happy to contribute to this feature if this is something you would like to add to the library.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or mute the thread.

yowakita commented 5 years ago

@tazsingh I just noticed there was work done to the repo recently and was wondering what you thought about incorporating this capability? I also would be interested in contributing if you need some help with this feature. Rootmargin would be very nice to have so that lazy loading content as you scroll down a page feels smoother (by giving it a larger offset/time to load the element before reaching the loadable content)

tazsingh commented 5 years ago

@yowakita I'm in favour of this capability and commented on a preferred solution on the PR: https://github.com/stratiformltd/react-loadable-visibility/pull/17#issuecomment-445846881

Essentially what I'd like to see there is a global function to handle setting the options, as the IntersectionObserver is a global itself.

I'm happy to review a PR if you'd like to submit one! Can close #17 in favour of a new one if you'd like also. Let me know.