Skip to content
Permalink
80a26e839a
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
24 lines (20 sloc) 583 Bytes
if (window.DeviceMotionEvent) {
window.addEventListener('devicemotion', deviceMotionHandler, false);
} else {
document.getElementById("warning").innerHTML = "Not supported."
}
function deviceMotionHandler(eventData) {
// Grab the acceleration from the results
var acceleration = eventData.acceleration;
var trimmedaccel = acceleration.x.toPrecision(2)
switch (trimmedaccel >= 0) {
case true:
$("body").addClass('up');
$("body").removeClass('down');
break;
case false:
$("body").addClass('down');
$("body").removeClass('up');
break;
}
}