Replaced the visibilityApi interface and custom callback stacks with a simple feature toggler that uses custom event types and the native event listener interface.
The new PageVisibility interface provides support for dispatching a custom event derived from the value of document.visibilityState when the visibilitychange event is fired.
The custom events are:
visibilityhidden representing the "hidden" visibility state.
visibilityvisible representing the "visibile" visibility state.
Example:
import pageVisibility from './utils/visibility.js';
pageVisibility.enableCustomEvents();
document.addEventListener('visibilityhidden', () => videoElement.pause());
The visibilitychange event is accessible from the detail property on the custom event:
Replaced the
visibilityApi
interface and custom callback stacks with a simple feature toggler that uses custom event types and the native event listener interface.The new
PageVisibility
interface provides support for dispatching a custom event derived from the value ofdocument.visibilityState
when thevisibilitychange
event is fired.The custom events are:
visibilityhidden
representing the "hidden" visibility state.visibilityvisible
representing the "visibile" visibility state.Example:
The
visibilitychange
event is accessible from thedetail
property on the custom event:The
PageVisibility
interface does not manage the attachment/detachment of event listeners on the custom event types.