HTMLCanvasElement: contextrestored イベント
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Experimental: これは実験的な機能です。
本番で使用する前にブラウザー互換性一覧表をチェックしてください。
contextrestored
はキャンバス API のイベtので、ユーザーエージェントが CanvasRenderingContext2D
のバッキングストレージを復元した場合に発行されます。
このイベントを受け取った後、再描画、リソースの再取得、コンテキストの状態の再初期化などが可能です。
構文
このイベント名を addEventListener()
などのメソッドで使用したり、イベントハンドラープロパティを設定したりしてください。
js
addEventListener("contextrestored", (event) => {});
oncontextrestored = (event) => {};
イベント型
一般的な Event
です。
例
次のコードは、コンテキストが復元されたイベントを検出するものです。
js
const canvas = document.getElementById("canvas");
canvas.addEventListener(
"contextrestored",
(e) => {
console.log(e);
// redrawCanvas() などを呼び出す
},
false,
);
仕様書
Specification |
---|
HTML # event-contextrestored |
ブラウザーの互換性
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
contextrestored event |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.