[TIMOB-7190] Add 'view' property to Ti.UI.Animation
| GitHub Issue | n/a |
|---|---|
| Type | New Feature |
| Priority | Low |
| Status | Open |
| Resolution | Unresolved |
| Affected Version/s | Release 1.8.0.1 |
| Fix Version/s | n/a |
| Components | TiAPI |
| Labels | animation, dr-list, improvement, pathmenu |
| Reporter | Tony Lukasavage |
| Assignee | Ingo Muschenetz |
| Created | 2012-01-15T14:09:24.000+0000 |
| Updated | 2015-04-13T20:09:52.000+0000 |
Description
Currently there is no way to know what view a
Ti.UI.Animation is operating on. So for example, if I want to perform another operation on the target view after the Animation completes, I need to add that reference directly to the Animation manually.
var view = Ti.UI.createView(/* set view properties */);
var animation = Ti.UI.createAnimation({
duration: 1000,
top: 100,
// I need to add this manually so that I know what view was animated in the upcoming 'complete' event
view: view
});
animation.addEventListener('complete', function(e) {
// There is no native property in Ti.UI.Aniamtion, nor the returned event object, that
// gives me access to the view being animated. Until this property is added, I'll have to
// use the property I added manually.
e.source.view.backgroundColor = '#f00';
});
view.animate(animation);
It would be much easier if when view.animate() was called, the Animate object automatically had the appropriate view added to it as a property.
I don't think this is necessary since the complete event is passed a "source" which would be the view that was animated. Here's the API docs: http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.Animation.complete-event.html
In my testing on iOS and Android,
e.sourcereturns theTi.UI.Animation, not the view that is animating.Sorry, you're right. That is how it will be in mobile web too. Perhaps this ticket should be to add a "target" to the Ti.UI.Animation start/complete events that would be the UI element being animated.