[✨] useOnVisible #272
Replies: 6 comments
-
Hmm I wonder if that's a bug. useVisibleTask should fire only when visible, IMHO. |
Beta Was this translation helpful? Give feedback.
-
@wmertens According to mhevery this is how it's working "for now" :
From his comment I think it can be confusing as developer might think it always execute code when the element enters the viewport. |
Beta Was this translation helpful? Give feedback.
-
Is there any update? |
Beta Was this translation helpful? Give feedback.
-
We are thinking of making it lazy, but it is dependant on other features landing first. |
Beta Was this translation helpful? Give feedback.
-
We moved this issue to |
Beta Was this translation helpful? Give feedback.
-
This requires that qwikloader re-subscribes the observer when the qvisible event is pushed again. Then it's just a matter of setting the handler on the DOM like all other events. This would also partially solve QwikDev/qwik#7757 |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Is your feature request related to a problem?
Currently
useVisibleTask$
runs:<a>
)<Link>
)This means that we cannot rely on it to lazy query data for example, as it'll be trigger eagerly with soft navigation.
Describe the solution you'd like
As qwik loader already has an
IntersectionObserver
, I think it could trigger a callback when the element is visible.Describe alternatives you've considered
Create a local hook for that, but it might be difficult to optimize.
Additional context
No response
Beta Was this translation helpful? Give feedback.
All reactions