[TIMOB-9177] MobileWeb: Update animate() to cancel animations
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2012-12-21T05:36:59.000+0000 |
Affected Version/s | Release 2.0.1 |
Fix Version/s | Sprint 2012-14 Core, Release 3.0.0 |
Components | MobileWeb |
Labels | n/a |
Reporter | Chris Barber |
Assignee | Chris Barber |
Created | 2012-05-19T17:45:19.000+0000 |
Updated | 2012-12-21T05:36:59.000+0000 |
Description
Apparently, the only way to stop an animation is to call animate() without any arguments.
Attachments
File | Date | Size |
---|---|---|
app.js | 2012-07-16T11:45:28.000+0000 | 2469 |
view.animate()
causes an exception in Android, whereas...cancels the animation. Haven't tried iOS. I wonder if we should all just agree on a View.cancelAnimation() to get in before 2.1? (or later perhaps if we're all booked-up for 2.1)
I full plan on implementing cancel/pause functionality internally for 2.1. I was going to wait on how we should expose it until A) I figured out how I'm going to handle it and B) what everybody thought the API should look like. I disagree with a cancelAnimation() function. I think we should go down the road of animate() returning a canceller function or handle or something, but I haven't quite formed a solution worth recommending.
Pull request: https://github.com/appcelerator/titanium_mobile/pull/2576
Verified.Thus closing. Tested On: Titanium studio : 2.1.1.201207271312 SDK version : 2.2.0.v20120731184111 Android 4.0.4 Iphone 5.0.1
@Chris: The PR is huge,so forgive me for asking rather than skimming code: did you implement some way to cancel an animation? I can't find any documentation anywhere, if so. I'm working on a community PR https://github.com/appcelerator/titanium_mobile/pull/2661 and Neeraj asked me to check with you about animation cancellation in MobileWeb.
to be clear, I meant a way for Titanium devs to cancel (i.e., not necessarily just internal code, which obviously wouldn't necessitate a change to the .yml files.)
Yes, you can cancel an animation in Mobile Web. The view.animate() function returns a modified promise object. Here's what the object returned by animate() should look like: Promise then(Function successCallback, Function errorCallback) // where promise.then() === promise. then() is used to be notified when the animation completes void resolve(...) // all arguments are considered the "result" and forwarded to all successCallbacks(). not intended to be called by user's app void reject(Error|String ex) // if ex is a string, convert it to an Error. in context of an animate() response, this method is not intended to be called by user's app Boolean pause() // returns true if success, otherwise false (for when the animation is already paused) Boolean resume() // returns true if success, otherwise false (for when the animation is already playing) Boolean cancel(Boolean reset) // returns true if success, otherwise false (for when animation is finished and no longer exists). reset argument restores animated view to original state
Continued... Properties: source (Ti.UI.View) animation (Ti.UI.Animation) // if animate() is called with an Object, the Object is promoted to a Ti.UI.Animation object None of those functions above are documented. Was intending to create a formal spec before documenting public access.