Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
adding in updown
  • Loading branch information
Joel Salisbury committed Jan 21, 2016
1 parent 79be0a4 commit 80a26e8
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
6 changes: 6 additions & 0 deletions css/main.css
Expand Up @@ -96,7 +96,13 @@ textarea {
========================================================================== */


.up {
background-color:red;
}

.down {
background-color:blue;
}



Expand Down
13 changes: 12 additions & 1 deletion js/main.js
Expand Up @@ -8,6 +8,17 @@ if (window.DeviceMotionEvent) {
function deviceMotionHandler(eventData) {
// Grab the acceleration from the results
var acceleration = eventData.acceleration;
$("#accelerationX").html(acceleration.x.toPrecision(2));
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;
}

}

0 comments on commit 80a26e8

Please sign in to comment.