2018-08-30 12:01:11 -06:00
|
|
|
'use strict'
|
2018-08-30 12:52:14 -06:00
|
|
|
/* global $ window */
|
2018-08-30 12:01:11 -06:00
|
|
|
|
|
|
|
|
2018-08-30 12:52:14 -06:00
|
|
|
window.addEventListener('deviceorientation', function(e){
|
2018-08-30 12:01:11 -06:00
|
|
|
|
2018-08-30 12:52:14 -06:00
|
|
|
// No orientation data
|
|
|
|
if(!e) $('#no-dir').show()
|
2018-08-30 12:01:11 -06:00
|
|
|
|
2018-08-30 12:52:14 -06:00
|
|
|
// Set orientation
|
|
|
|
else {
|
|
|
|
$('#no-dir').hide()
|
|
|
|
const rot = 'rotate('+e.alpha.toString().substring(0,5)+'deg)'
|
|
|
|
$('#rose').css({
|
|
|
|
'-ms-transform': rot,
|
|
|
|
'-webkit-transform': rot,
|
|
|
|
'transform': rot
|
|
|
|
})
|
|
|
|
}
|
2018-08-30 12:01:11 -06:00
|
|
|
|
2018-08-30 12:52:14 -06:00
|
|
|
}, true)
|