From 01397c52ac7327ce806957ff06482ef4bc7bbd0d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=9Cchrisshank=E2=80=9D?= Date: Fri, 20 Dec 2024 13:32:35 -0800 Subject: [PATCH] update demo --- ...event-propagators-with-device-gravity.html | 23 +++++++++++++++---- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/website/canvas/event-propagators-with-device-gravity.html b/website/canvas/event-propagators-with-device-gravity.html index fd04998..d95bd23 100644 --- a/website/canvas/event-propagators-with-device-gravity.html +++ b/website/canvas/event-propagators-with-device-gravity.html @@ -34,6 +34,7 @@ + Hello World { + function onDeviceOrientation(e) { console.log(event); - // ropes.forEach(rope => { rope.gravity = { x: 0, y: 0} }) - }); + // ropes.forEach(rope => { rope.gravity = { x: 0, y: 0} }) + } + + async function enableGravity() { + if (DeviceOrientationEvent.requestPermission) { + const permission = await DeviceOrientationEvent.requestPermission(); + + if (permission === "granted") { + window.addEventListener("deviceorientation", onDeviceOrientation); + } else { + console.warn('Permission for device orientation rejected', permission) + } + } else { + window.addEventListener("deviceorientation", onDeviceOrientation); + } + }