Exposure
Know when elements scroll into or out of view, per element or for the whole page. import { LynxExposure, LynxGlobalExposure, type ExposureEventDetail, type GlobalExposureEvent, type ObserverFrameRateOptions } from '@blotch/angular-lynx';
Exposure is Lynx's name for an element becoming visible on screen, like the web's IntersectionObserver.
Usage
API
LynxExposure
Tracks whether its element is in the visible area of its scroll container. It listens for the element's binduiappear and binduidisappear events, and works without LynxGlobalExposure.
LynxExposure.visible
true while the element is on screen. Starts false. Read it through the template reference, as in Usage.
LynxGlobalExposure
Reports page-wide exposure in batches for every element that has an exposure-id. Use it for impression tracking across many elements.
LynxGlobalExposure.exposures
The most recent batch of elements that came into view. Each batch replaces the last one.
LynxGlobalExposure.disexposures
The most recent batch of elements that left the view.
LynxGlobalExposure.active
Whether page-wide detection is running. Starts true. stopExposure() and resumeExposure() set it.
LynxGlobalExposure.stopExposure()
Pauses page-wide detection. LynxExposure keeps working.
LynxGlobalExposure.resumeExposure()
Restarts page-wide detection.
LynxGlobalExposure.setObserverFrameRate()
Sets how often Lynx checks for exposure, and resolves once it's applied. Lynx provides it only on the background thread, so a call from an event handler is sent there for you.
Attributes
Every Lynx element accepts these attributes. Give an element exposure-id to include it in LynxGlobalExposure. Write them as static attributes, such as exposure-area="50%".
Types
ExposureEventDetail
One element in a batch. Lynx sends the ID and scene twice, in kebab case and camel case. unique-id identifies the native element.
GlobalExposureEvent
One batch.
