Open theonlychase opened 1 year ago
you can add an attribute to the element and check the value
@theonlychase is it solved?
Hello @theonlychase. Please provide the missing information requested above.
Issues marked with STATUS-2: missing info
will be automatically closed if they have no activity within 14 days.
Thanks 🙏
Is your feature request related to a problem?
The problem I am having is not being able to remove an event listener after it is invoked once, either by setting it on the element itself, or by creating an event using the useOn hook.
Describe the solution you'd like
The ability to set any of the event listener options, such as
{ once: true }
. The event listener would automatically be removed after being invoked once.Describe alternatives you've considered
As an example, I am currently using state to handle a window onScroll event that I only want triggered once based on the scroll position.
Additional context
Another option is using an intersection observer. I understand there is
useVisibleTask?()
, which can use an observer under the hood, but there is no way to set any of the Intersection Observer Options, or see the properties on the entry itself, such as the intersectionRatio. If the component/element is above the fold on page load, that Javascript gets loaded right away, which I want to avoid.