[TIMOB-14005] Android: Animation with transform not working
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2013-10-22T23:29:08.000+0000 |
Affected Version/s | n/a |
Fix Version/s | 2013 Sprint 22, 2013 Sprint 22 Core, Release 3.2.0 |
Components | Android |
Labels | android, animation, module_animation, qe-testadded, transform |
Reporter | Carter Lathrop |
Assignee | Bill Dawson |
Created | 2013-05-27T15:43:57.000+0000 |
Updated | 2014-02-24T10:55:43.000+0000 |
Description
If you run the sample and tap on the red rectangle, it should animate from on position to another.
It works great on iOS.
It doesnt work on Android.
var win = Ti.UI.createWindow({
backgroundColor:'gray'
});
var isTransformed = false;
var view = Ti.UI.createView({
width:100,
height:150,
backgroundColor:'red'
})
view.addEventListener('singletap', function(){
if (isTransformed) {
view.animate({transform:Ti.UI.create2DMatrix(), duration:200});
}
else {
view.animate({transform:Ti.UI.create2DMatrix().translate(-50, 40).scale(0.2,0.4), duration:200});
}
isTransformed = !isTransformed;
})
win.add(view);
win.open();
Martin, What exactly doesn't work for you? I have tested on device, Galaxy S3 and it is transforming as expected though admittedly not as smoothly as it does for iOS. Is this the 'not working' you are describing? Please try to be more clear in your description, what usually helps is having an Expected vs Actual behavior. Please see here: https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report for future reference. Regards, Carter
Martin: You could also try the test case I added at TC-1342 I'm also interested in this issue because view.animate() crashes in my [slider menu for Android](http://www.danielsefton.com/2013/05/slider-menu-widget-v2-for-titanium-alloy/), unfortunately I can't reproduce it with simple test cases :(
@Carter: Sorry i should have been more detailed. I thought the simple test code would say it all :) So what you see is a red rectangle going back and forth from a scaled and translated position to a centered position. It works great on iOS, but it doesnt on Android. And i find it really hard to believe that it works for you because seeing the code it s impossible. Actually i have tackled that bug a few times already without finding a good solution. It s all the 2DMatrix class which needs rewrite for that to work i think :s This is because when you animate a transform, it works only if you animate from identity, if it s not identity the interpolate wont work. I have looked at changing it all to use quaternion and slerp but it didnt work as planned ;) That s why i created that bug
@Daniel: Can you give us a logcat on your crash? Also i created a native slidermenu for ios and android, it works great. It s integrated in my private branch of Titanium. I hope to merge that with you guys ;)
Ok, so it is the animation that is broken, but the transform is working fine that is what I was talking about. Reproduced on device: Galaxy S3 Ti SDK 3.1.0GA Titanium Studio, build: 3.1.0.201303032333 Moving to Ti-Mobile
Testing Notes
Test is precisely the JS code given above - use it as app.js in a new project. When you run it, if you tap the red box it should shrink. Tap it again and it should grow again. Etc.PR: https://github.com/appcelerator/titanium_mobile/pull/4662
Bill, this is a good idea to use translatex... But it wont work with complex matrices. This is because you need to decompose he matrix and using the operations like you do wont work. You can compare to the ios counterpart where everything is done by quartz. Plus your implementation will only work when going from or to the identity matrix. I posted a video of the result of my implementation. http://m.youtube.com/channel/UCZSYQNBf3yOr6WwDWIJGleg#/watch?v=A7yCg6bwRec&feature=c4-feed-u
Bill, this is a good idea to use translatex... But it wont work with complex matrices. This is because you need to decompose he matrix and using the operations like you do wont work. You can compare to the ios counterpart where everything is done by quartz. Plus your implementation will only work when going from or to the identity matrix. I posted a video of the result of my implementation. http://m.youtube.com/channel/UCZSYQNBf3yOr6WwDWIJGleg#/watch?v=A7yCg6bwRec&feature=c4-feed-u
Actually i have been thinking about it. Your implementation should work from/to any matrix. I am only worried about the computation of the correct rotation/scale ...
Actually i have been thinking about it. Your implementation should work from/to any matrix. I am only worried about the computation of the correct rotation/scale ...
Test Environment - Appc Studio - 3.2.0.201310240448 SDK - 3.2.0.v20131023171643 acs -1.0.7 alloy - 1.2.2 titanium - 3.2.0 titanium-code-processor - 1.0.3 Xcode - 5.0.1 OS - Mac OS X Mavericks (10.9) Device - Nexus7(v4.3), iPhone5(v7.0.2) Result - Now its working fine. Verified on Android and iOS both. Hence closing this issue.