Looking to adjust the position of an image on my iPad3, but running into some difficulties.
The movement isn't as smooth as desired and seems to lag behind the gestures being made.
This is what I have so far (a 3MB base64 image)
<img src="data:image/jpeg;base64,/9j/4AAQ....">
CSS:
img {
transform: translate3d(0,0,0);
}
And here's the JavaScript:
img.on('touchstart', function (e) {
var diffX = e.pageX;
var diffY = e.pageY;
img.on('touchmove', function (e) {
translateX += e.pageX - diffX;
translateY += e.pageY - diffY;
img.css({'-webkit-transform': 'translate(' + translateX + 'px, ' + translateY + 'px)'});
diffX = e.pageX;
diffY = e.pageY;
});
return false;
})
...
This setup works well on my laptop, however, not on my iPad3. I've also experimented with requestAnimationFrame, but it only updates once I stop moving. Any suggestions for improving performance on my iPad?