-
Notifications
You must be signed in to change notification settings - Fork 22.4k
/
index.md
68 lines (44 loc) · 1.78 KB
/
index.md
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
---
title: "XRCubeLayer: redraw event"
short-title: redraw
slug: Web/API/XRCubeLayer/redraw_event
page-type: web-api-event
status:
- experimental
browser-compat: api.XRCubeLayer.redraw_event
---
{{APIRef("WebXR Device API")}}{{SeeCompatTable}}
The `redraw` event is sent to the `XRCubeLayer` object when the underlying resources of the layer are lost or when the XR Compositor can no longer reproject the layer. If this event is sent, authors should redraw the content of the layer in the next XR animation frame.
See also the {{domxref("XRCompositionLayer.needsRedraw")}} property which is also available to `XRCubeLayer` objects through inheritance from {{domxref("XRCompositionLayer")}}.
## Syntax
Use the event name in methods like {{domxref("EventTarget.addEventListener", "addEventListener()")}}, or set an event handler property.
```js
addEventListener("redraw", (event) => {});
onredraw = (event) => {};
```
## Event type
An {{domxref("XRLayerEvent")}}. Inherits from {{domxref("Event")}}.
## Event properties
_In addition to the properties listed below, properties from the parent interface, {{domxref("Event")}}, are available._
- {{domxref("XRLayerEvent.layer", "layer")}} {{ReadOnlyInline}}
- : The {{domxref("XRLayer")}} which generated the event.
## Examples
### Using the `redraw` event
You can pass `redraw` to {{domxref("EventTarget.addEventListener()", "addEventListener()")}}:
```js
cubeLayer.addEventListener("redraw", (event) => {
// redraw the layer
});
```
Alternatively, you can use the `onredraw` event handler property to establish a handler for the `redraw` event:
```js
cubeLayer.onredraw = (event) => {
// redraw the layer
};
```
## Specifications
{{Specifications}}
## Browser compatibility
{{Compat}}
## See also
- {{domxref("XRCompositionLayer.needsRedraw")}}