[TIMOB-2229] iOS: animate does not change the property value
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Trivial |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2011-12-04T16:34:26.000+0000 |
Affected Version/s | Release 1.6.0 |
Fix Version/s | n/a |
Components | iOS |
Labels | parity |
Reporter | netspy |
Assignee | Reggie Seagraves |
Created | 2011-04-15T03:14:12.000+0000 |
Updated | 2012-02-10T00:48:36.000+0000 |
Description
If I animate an property of an ui element, the property does not change the value after animation.
Example:
var search = Titanium.UI.createSearchBar({
height: 43,
top: -43
});
win.add(search);
search.animate({top:0});
Ti.API.info(search.top);
Output: -43
Expected result: 0
The search bar is animated but the top property has not changed the value.
This is not a bug in animation. The bug is expecting a layout parameter to be updated after an animation. We will be adding contentRect or something equivalent which will tell you where your view is on the display in the next release.
This may be expected behavior. Final value can be set on end event.
If I animate an object from point a to point b, I expect the view state to reflect that movement. Setting the final value with a 'complete' event feels hacky. I understand that my reasoning is not correct, could you explain why the current behavior is the expected one?
Keith, just to clarify layout parameters aren't the same as view properties. It was a bug in iOS that height was changed to be the current height for example. When height is "auto" it should stay that way so that when orientation changes occur the information is still available to layout the display. For example if you set width 50% and as soon as the view is drawn it changes to 150 then you've lost the layout configuration when other container views change. I'm sending a note to our doc go to talk about this in the animation as you suggest.
Is there a way to access the view's active properties? I understand there is a separation between the native object's current properties and the view object's properties, but if views can be moved around onscreen without exposing their current positions somewhere, it seems buggy at best.
You can use a view's
size
property to get the view's active properties. For example, if you set the initial layout value of an ios view to have a width of 50%, the value in view.size.width would be 160. The size property is a dictionary that looks like this:Note that the
size
property only gives you the object's size (as the name suggests). As Don said in his first comment, the position half of the equation is missing. This is a known issue. The current situation is frustrating. But I will document it for 1.8.0 so it isn't frustrating AND mysterious.See the comments. APIDoc is being added to help.