I have an image larger than viewport that I'm trying to pan on the x plan according to device Acceleration value.
_____________________
| |
| Device |
| |
________|___________________|__________
| | | |
| | Image | |
| | | |
|_______|___________________|_________|
| |
| |
| |
| |
|___________________|
<-------------------->
X axis
I can get to semi-decent results but nothing like great.
From my understanding I need to :
- get the acceleration value
- get the object position
- combine these two value (maybe with frequency ?)
- Apply the new position to the object
So far I have something like : (I'm using gyronorm.js so the acceleration data is called data.dm.x
)
var accelX = data.dm.x
var currTrans = $('#pano').css('-webkit-transform').split(/[()]/)[1]
var posX = parseInt(currTrans.split(',')[4])
var newPos = posX+accelX
$('#pano').css({'-webkitfr-transform':'translateX('+(newPos)+'px)'})
I feel like I'm missing a core concept here but after hours of research I wasn't able to find it.