Visibility API
Programmatically show and hide the widget with show(), hide(), isHidden, and isShownOnReady.
The visibility API is available at instance.visibility. It provides reactive state and methods for showing and hiding the widget at runtime — useful for deferred rendering, conditional display, or toggling the widget in response to user actions on the host page.
const visibility = instance.visibility;
Properties
| Property | Type | Description |
|---|---|---|
isHidden | boolean | Whether the widget is currently hidden |
isShownOnReady | boolean | Whether the widget auto-shows when the video is ready |
Methods
| Method | Signature | Description |
|---|---|---|
show | () => void | Show the widget |
hide | () => void | Hide the widget |
Usage
// Hide the widget
instance.visibility.hide();
// Show it later
instance.visibility.show();
// Check state
if (instance.visibility.isHidden) {
instance.visibility.show();
}
Events
Visibility changes emit events on the event bus:
import { ScenaEvent } from '@retoo/scena';
instance.api.events.on(ScenaEvent.ON_VISIBILITY_SHOW, () => {
console.log('Widget is now visible');
});
instance.api.events.on(ScenaEvent.ON_VISIBILITY_HIDE, () => {
console.log('Widget is now hidden');
});