@serenity-is/corelib / LazyLoadHelper / executeOnceWhenShown
Variable: executeOnceWhenShown()
constexecuteOnceWhenShown: (el,callback) =>number=executeOnceWhenVisible
Defined in: src/ui/helpers/lazyloadhelper.ts:10
Executes the given callback once when the element becomes visible.
Executes a callback once when the element becomes visible.
If the element is already visible (positive offsetWidth / offsetHeight), the callback is invoked immediately and null is returned.
Otherwise registers via LayoutTimer.onShown and auto-unregisters after the first fire.
Parameters
el
Target element or array-like collection (first element is used).
HTMLElement | ArrayLike<HTMLElement>
callback
Function
Function to invoke when visible.
Returns
number
The LayoutTimer registration key, or null if already visible / element missing.
Deprecated
Prefer IntersectionObserver or ResizeObserver. Kept for legacy triggerLayoutOnShow compatibility.