Questions tagged [devicemotion]

72 questions
3
votes
2 answers

Why is the motion event not triggered?

I have a problem while trying to get the accelerometer data using the HTML 5 interface. I declare this handler event: window.addEventListener("devicemotion",getMontionData,true); to get the data provided by the accelerometer sensor. On the other…
2
votes
1 answer

IOS safari 13.1 permission for DeviceMotionEvent

DeviceMotionEvent.requestPermission work well for the first use. If user cancel access for motion sensors in first time dialog window will not appear for future calls of requestPermission function. And promise is always fulfilled with response ===…
Alex Grigorenko
  • 403
  • 4
  • 12
2
votes
0 answers

CoreMotion - Recognizing a jump (Swift)

I'm pretty new to CoreMotion but I'm trying to build an app that uses CoreMotion to see if a user is jumping up and down (think skipping rope). It also need to allow the user to be able to hold their phone (no iWatch) however they want (landscape,…
Henrik
  • 69
  • 1
  • 2
  • 4
2
votes
0 answers

check for DeviceMotionEvent Javascript

I am making an interactive web-app that needs to check if there is a gyroscope present on the current device. I need to do this check once before all the other javascript is loaded. I found the following article on how to do this. But when i try…
FutureCake
  • 2,614
  • 3
  • 27
  • 70
2
votes
0 answers

HTML5/Javascript (devicemotion/deviceorientation) Reset rotation values to zero depending on how the user is holding the device when code is run

At the moment my code looks like this: window.ondevicemotion = function(event) { if ( offsetX === undefined) { offsetX = event.accelerationIncludingGravity.x; } else { event.stopPropogation; } var x =…
2
votes
1 answer

How to transfer 'devicemotion' property in JavaScript?

I have a DOM element (in some cases several) that I want to move (by changing the css) when the device moves. Now, I wonder why this doesn't work: var aDOMElement = document.getElementById("someId"); aDOMElement.DeviceMotionEvent =…
Gandora
  • 195
  • 1
  • 18
1
vote
0 answers

deviceMotionEvent.acceleration properties returning null in mobile browser

I'm trying to detect acceleration of a mobile device. I've already tried using Accelerometer and now I'm also trying deviceMotionEvent. Whenever I print the properties event.acceleration.x, .y, or .z either in html or console, I'd get null. It…
1
vote
0 answers

How to set interval in DeviceMotionEvent javascript

I have code which is written: if ('DeviceMotionEvent' in window) { deviceMotion = new DeviceMotionEvent("devicemotion", {interval: 20, acceleration:DeviceMotionEventAcceleration}); window.addEventListener("devicemotion",…
Nanetta
  • 101
  • 13
1
vote
0 answers

devicemotion api device coordinate frame

The DeviceMotionEvent API appears to provide acceleration data with reference to the world's coordinate frame. x - Represents the acceleration upon the x axis which is the west to east axis y - Represents the acceleration upon the y axis which is…
David Callanan
  • 5,601
  • 7
  • 63
  • 105
1
vote
1 answer

Devicemotion event on iOS

I want to implement mobile device "shake" event both for Android and iOS platforms on my webpage. So, I immediately found one and only script written by Alex Gibson. After some tests I found out that it works on Android phone perfectly. On iPhone it…
mr.boris
  • 3,667
  • 8
  • 37
  • 70
1
vote
2 answers

DeviceMotionEvent.requestPermission() is not a function on Chrome + Safari Desktop

In iOS 12.2 Apple removed the motion sensors by default from mobile Safari. Chrome did something similar recently too. In iOS 13, a requestPermission popup was added back. .then(response => { if (response == 'granted') { …
Unome
  • 6,750
  • 7
  • 45
  • 87
1
vote
2 answers

DeviceMotion and DeviceOrientation in WKWebView iOS 13

I want to use DeviceMotion and DeviceOrientation events in WKWebView in iOS 13+. I am using below code