Strange behaviour of GestureEvent.rotation on iOS webkit

23 views
Skip to first unread message

stan wiechers

unread,
Apr 27, 2012, 12:55:49 PM4/27/12
to iPhoneWebDev
Hey,

I'm having a question regarding the rotation property of the Gesture
Event in the iOS Webkit Browser, also posted that on stackoverflow:
http://stackoverflow.com/questions/10336802/strange-behaviour-of-gestureevent-rotation-on-ios-webkit

I am using javascript Gesture events to detect multitouch pan/scale/
rotation applied to an element in a HTML document.

Visit this URL with an iPad or iPhone: http://www.merkwelt.com/people/stan/rotate_test/

You can touch the element with two finger and rotate it, but sometimes
the rotation property goes go astray and my element flips around many
full rotations.

Here is part of my code, I am really only taking the value directly
from the event object:

...bind("gesturechange",function(e){
e.preventDefault();
curX = e.originalEvent.pageX - startX;
curY = e.originalEvent.pageY - startY;
node.style.webkitTransform = "rotate(" +
(e.originalEvent.rotation) + "deg)" +
" scale(" + e.originalEvent.scale + ")
translate3D(" + curX + "px, " + curY + "px, 0px)";
}...
What happens is that the value gets either 360 degrees added or
subtracted, so I could monitor the value and react to sudden large
changes, but this feels like a last resort.

Am I missing something obvious?

Thankful for any leads,
Stan
Reply all
Reply to author
Forward
0 new messages