Move image to top left of screen
I am developing a mobile app and I am trying to animate an imageView from its default position (about the middle of the screen) to the top left of the screen, while shrinking it.
Here's what I have…
t = Ti.UI.create2DMatrix();
t = t.scale(size);
var asdf=Ti.UI.createAnimation({
transform:t,
top:0,
left:0,
duration:1000
});
img.animate(asdf);
This scales the image down but does not move it.
So my question is two-fold. First, how do I find the top left of the window. Second, how do I get something to move there?
1 Answer
-
For movement, you'd want to use translate on your matrix
So, you could do something like
t = Ti.UI.create2DMatrix(); t = t.scale(size).translate(100,-100);
Play around with those values to get both a scale (increase/decrease in size) and translate(movement of x,y)
To go back to the previous transform, you can simply create an empty 2DMatrix and pass it back to animate again. This is called the identity matrix.