utily / smoothly

Web component library written with Stencil.
https://payfunc.com/open-source/smoothly
MIT License
1 stars 5 forks source link

Add scroll triggerMode to smoothly-load-more #838

Closed Magnus93 closed 3 weeks ago

Magnus93 commented 1 month ago

The flaw of using intersection

Using the intersection has the issue that the it only triggers when the element enters view, not while in view.

This means sometimes to trigger the loadMore you have to scroll away and then back again. This is especially true when the contents that load in don't push the smoothly-load-more component enough to move out of view.

Scroll

This PR is adding the ability to listen to scroll instead of Intersection. This will trigger a smoothlyLoadMore event on scroll if the element is in view.

The problems with scroll is that it will trigger a lot of events, so it's not recommended to use if you don't have some debouncing for when listening to the event.

Alternative triggerMode names

The triggerMode could be called something triggerOn with valus like

"enterScreen" | "onScreen" or "enterView" | "inView" Since this is basically the difference between them.

cloudflare-pages[bot] commented 1 month ago

Deploying smoothly with  Cloudflare Pages  Cloudflare Pages

Latest commit: ca8e5ba
Status: ✅  Deploy successful!
Preview URL: https://9fe19cf7.smoothly.pages.dev
Branch Preview URL: https://check-load-more-on-scroll-pr.smoothly.pages.dev

View logs