The following animation technique is broken in the current 1.5
continuous builds. Verified on iOS. http://developer.appcelerator.com/question/86311/ios---sdk-150---imageview-resets-to-center-before-animating">
Community question Attached movie showing behavior:
Titanium.UI.setBackgroundColor('#000');
var win = Titanium.UI.createWindow({
title:'Window',
backgroundColor:'#fff',
backButtonName:'Back'
});
var imageView=Ti.UI.createImageView({
image:'default_app_logo.png',
zIndex:1
});
var moveImageOneSecButton=Ti.UI.createButton({
title:'Move: Duration 1 Sec',
top: 10,
width:200,
height:40,
zIndex:2
});
moveImageOneSecButton.addEventListener('click', function(){
var newX=imageView.center.x + 10;
var newY=imageView.center.y + 10;
imageView.animate({
center: {
x: newX,
y: newY
},
duration: 1000
});
imageView.center.x=newX;
imageView.center.y=newY;
});
var moveImageOneMilliButton=Ti.UI.createButton({
title:'Move: Duration 1 millisec',
top: 60,
width:200,
height:40,
zIndex:2
});
moveImageOneMilliButton.addEventListener('click', function(){
var newX=imageView.center.x + 10;
var newY=imageView.center.y + 10;
imageView.animate({
center: {
x: newX,
y: newY
},
duration: 1
});
});
var resetImageButton=Ti.UI.createButton({
title:'Reset Image',
top: 110,
width:200,
height:40,
zIndex:2
});
resetImageButton.addEventListener('click', function(){
var newX=win.center.x;
var newY=win.center.y;
imageView.animate({
center: {
x: newX,
y: newY
},
duration: 1
});
});
win.add(imageView);
win.add(moveImageOneSecButton);
win.add(moveImageOneMilliButton);
win.add(resetImageButton);
win.open();
Code is being checked in, but part of the issue is that the current iphone spec ignores x and y when width or height is missing. The animation was still using x and y, against the spec, and the layout was honoring the spec, setting things fullscreen.
Short version: After the code checkin, the animation will work, but you MUST specify a width and height to the view, even if it's 'auto' or a percentage.
(from [83683409c6e93e0977241a2fb5ca9229220ed902]) [#2508 state:fixed-in-qa] Center is properly stored into the proxy's layoutProperties, which makes animation correct https://github.com/appcelerator/titanium_mobile/commit/83683409c6e93e0977241a2fb5ca9229220ed902"> https://github.com/appcelerator/titanium_mobile/commit/83683409c6e9...
Successful iOS Simulator, iOS Device, and Android Emulator test on 01/26/2011
Mobile SDK version: 1.6.0 (01/25/11 13:33 1f1dd51...)
Device/Version: iPhone 4 / 4.2.1
Simulator Version: 4.2 (235)
Emulator SDK: APIs 2.1
rollback wrong update