0

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?

ShaunaL
  • 31
  • 5

1 Answers1

1

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.

Raanan W
  • 1,295
  • 7
  • 19
  • Yes, I agree with the down voting....tough crowd. Thank you for answering. I have tried the visibilitychange type; – ShaunaL Feb 19 '20 at 19:41
  • I have tried `visibilitychange` on different targets (window, document, navigator), unsuccessful. From the document link above, looks like the target has to be session. If I am adding my event listeners at `init()`, there is no session. Maybe my original question should be; is there an event listener for `WebXRManager.isPresenting:true` – ShaunaL Feb 19 '20 at 19:57
  • Once you started a session, you know that it has started. afterwards you attach event listeners to the session to know when it stopped or changed. – Raanan W Feb 20 '20 at 07:41