Skip to content

Commit

Permalink
Asdf
Browse files Browse the repository at this point in the history
  • Loading branch information
raggeju committed May 3, 2024
1 parent 920a54d commit c844aa5
Showing 1 changed file with 36 additions and 33 deletions.
69 changes: 36 additions & 33 deletions accel-demo/index.html
Original file line number Diff line number Diff line change
@@ -1,41 +1,44 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Accelerometer Demo</title>
<head>
<meta charset="UTF-8" />
<title>Accelerometer Demo</title>

<style>
.indicatorDot{
width: 30px;
height: 30px;
background-color: #ffab56;
border-radius: 50%;
position:fixed;
}
</style>
<style>
.indicatorDot {
width: 30px;
height: 30px;
background-color: #ffab56;
border-radius: 50%;
position: fixed;
}
</style>

<script>
function getAccel(){
DeviceMotionEvent.requestPermission().then(response => {
if (response == 'granted') {
// Add a listener to get smartphone acceleration
function getAccel() {
const indicatorDot = document.querySelector("indicatorDot");
DeviceMotionEvent.requestPermission().then((response) => {
if (response == "granted") {
// Add a listener to get smartphone acceleration
// in the XYZ axes (units in m/s^2)
window.addEventListener('devicemotion', (event) => {
console.log(event.acceleration.x.valueOf());
console.log(event.acceleration.y.valueOf());
window.addEventListener("devicemotion", (event) => {
indicatorDot.clientLeft = event.acceleration.x.valueOf();
indicatorDot.clientTop = event.acceleration.y.valueOf();
});
// Add a listener to get smartphone orientation
// in the alpha-beta-gamma axes (units in degrees)
window.addEventListener('deviceorientation',(event) => {
// console.log(event.);
// Add a listener to get smartphone orientation
// in the alpha-beta-gamma axes (units in degrees)
window.addEventListener("deviceorientation", (event) => {
// console.log(event.);
});
}
});
}
</script>
</head>
<body style="background-color:lightblue;">
<button id="accelPermsButton" style="height:50px;" onclick="getAccel()"><h1>Get Accelerometer Permissions</h1></button>
<div class="indicatorDot" style="left:30%; top:30%;"></div>
</body>
</html>
}
});
}
</script>
</head>
<body style="background-color: lightblue">
<button id="accelPermsButton" style="height: 50px" onclick="getAccel()">
<h1>Get Accelerometer Permissions</h1>
</button>
<div class="indicatorDot" style="left: 30%; top: 30%"></div>
</body>
</html>

0 comments on commit c844aa5

Please sign in to comment.