Animation position bug?
I'm fairly new to Titanium so I'm not sure if this is a bug or a misuse on my part but I think I've found an issue with imageviews and animation. If I create an imageview, display its position, then animate it 200 pixels to the right and display its position again, there is no change in position. I am using left and top positioning in all cases (not center). I have tried the very same thing using center positioning and animatedCenter but I get the same result. Has anyone else seen this behavior? Is it a reported bug?
An example of my situation (I'm simplifying the real code):
var myImageview = Titanium.UI.createImageView({
url:'image.png',
width:100,
height:100,
left:0,
top:0
});
myWindow.add(myImageview);
alert(myImageview.left);
myImageview.animate({left:200}, function(){alert(myImageview.left);
});
…both times it reports "0", whereas I would expect it to be 0 in the first case and 200 in the second.
3 Answers
-
Accepted Answer
I think you actually have to pass the new centered point with the animate function. See this example: http://github.com/appcelerator/KitchenSink/blob/master/1.3.x/KitchenSink/Resources/examples/animation_points.js … its exactly what you're trying do plus it also moves down. Download kitechsink and look under animation to see the demo.
-
Try this
var a = Ti.UI.createAnimation(); a.left = 200; a.duration = 500; myImageview.animate(a);
-
Has anyone encountered this issue? Can anyone prove it working (with either method described here) so I can narrow it down to my own mistake? I am pretty much dead in the water with some core code I'm developing until I solve this. Any help is GREATLY appreciated. Thanks.