HTMLCanvasElement: elementgeometryupdate event
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Want more browser support for this feature? Tell us why.
The elementgeometryupdate event of the Canvas API is fired when drawable element geometry has been updated via an OffscreenCanvas.
This includes when geometry has been updated automatically during a OffscreenCanvasRenderingContext2D.drawElementImage() call, or manually using an OffscreenCanvas.updateElementGeometry() call.
Syntax
Use the event name in methods like addEventListener(), or set an event handler property.
addEventListener("elementgeometryupdate", (event) => { })
onelementgeometryupdate = (event) => { }
Event type
Examples
>Reporting geometry updates from an offscreen canvas
Our Canvas 2D context offscreen canvas example (source code) shows how to render an element on an offscreen canvas using drawElementImage().
In this example, our main thread includes an elementgeometryupdate event handler on the <canvas> that logs the drawable elements whose geometry has been changed via the worker (the resulting array will only contain a reference to the <form> element), and the transform DOMMatrix applied to it (retrieved using getElementTransform()):
canvas.addEventListener("elementgeometryupdate", (e) => {
console.log("Geometry update:", e.elements);
console.log(canvas.getElementTransform(e.elements[0]));
});