--- title: 'Window: vrdisplaypresentchange event' slug: Web/API/Window/vrdisplaypresentchange_event tags: - Evènement - Reference - WebVR - onvrdisplaypresentchange - vrdisplaypresentchange translation_of: Web/API/Window/vrdisplaypresentchange_event ---
{{APIRef("Window")}}

L'événement vrdisplaypresentchange de l'API WebVR est déclenché lorsque l'état de présentation d'un affichage VR change — c'est à dire passe de la présentation à la non présentation, ou vice versa.

Bulles Non
Annulable Non
Interface {{domxref("VRDisplayEvent")}}
Propriété de gestionnaire d'événements onvrdisplaypresentchange

Exemples

Vous pouvez utiliser l'événement vrdisplaypresentchange dans une méthode addEventListener :

window.addEventListener('vrdisplaypresentchange', function() {
  if(vrDisplay.isPresenting) {
    info.textContent = "L'affichage a commencé à présenter.";
  } else {
    info.textContent = "L'affichage a cessé de se présenter.";
  }
  reportDisplays();
});

Ou utilisez la propriété de gestionnaire d'événements onvrdisplaypresentchange :

window.onvrdisplaypresentchange = function() {
  if(vrDisplay.isPresenting) {
    info.textContent = "L'affichage a commencé à présenter.";
  } else {
    info.textContent = "L'affichage a cessé de se présenter.";
  }
  reportDisplays();
};

Spécifications

Spécification Statut Commentaire
{{SpecName('WebVR 1.1', '#dom-window-onvrdisplaypresentchange', 'vrdisplaypresentchange')}} {{Spec2('WebVR 1.1')}} Définition initiale

Compatibilité des navigateurs

{{Compat("api.Window.vrdisplaypresentchange_event")}}

Voir également