Search code examples
javascriptaddeventlistenerwebxr

Event Listener for Web XR


In the Web VR API there was an event listener for entering/exiting VR display;

window.addEventListener('vrdisplaypresentchange', function() {
//do something
}

Is there an equivalent for the Web XR API?


Solution

  • Not really sure why it was downvoted (twice!).

    The WebXR specs define a few events:

    https://www.w3.org/TR/webxr/#event-types

    As you can see there, there is a visibilitychange event (https://www.w3.org/TR/webxr/#eventdef-xrsession-visibilitychange) that might be helpful, but it really depends on what you are trying to achieve.