@hughsk/fulltilt
Version:
Standalone device orientation + device motion normalization and conversion library
41 lines (22 loc) • 799 B
JavaScript
////// Internal Event Handlers //////
function handleScreenOrientationChange () {
if ( hasScreenOrientationAPI ) {
screenOrientationAngle = ( window.screen.orientation.angle || 0 ) * degToRad;
} else {
screenOrientationAngle = ( window.orientation || 0 ) * degToRad;
}
}
function handleDeviceOrientationChange ( event ) {
sensors.orientation.data = event;
// Fire every callback function each time deviceorientation is updated
for ( var i in sensors.orientation.callbacks ) {
sensors.orientation.callbacks[ i ].call( this );
}
}
function handleDeviceMotionChange ( event ) {
sensors.motion.data = event;
// Fire every callback function each time devicemotion is updated
for ( var i in sensors.motion.callbacks ) {
sensors.motion.callbacks[ i ].call( this );
}
}