Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9177] MobileWeb: Update animate() to cancel animations

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2012-12-21T05:36:59.000+0000
Affected Version/sRelease 2.0.1
Fix Version/sSprint 2012-14 Core, Release 3.0.0
ComponentsMobileWeb
Labelsn/a
ReporterChris Barber
AssigneeChris Barber
Created2012-05-19T17:45:19.000+0000
Updated2012-12-21T05:36:59.000+0000

Description

Apparently, the only way to stop an animation is to call animate() without any arguments.

Attachments

FileDateSize
app.js2012-07-16T11:45:28.000+00002469

Comments

  1. Bill Dawson 2012-06-08

    view.animate() causes an exception in Android, whereas...
       view.animate({});
       
    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)
  2. Chris Barber 2012-06-08

    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.
  3. Chris Barber 2012-07-16

    Pull request: https://github.com/appcelerator/titanium_mobile/pull/2576
  4. Lokesh Choudhary 2012-08-01

    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
  5. Bill Dawson 2012-08-08

    @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.
  6. Bill Dawson 2012-08-08

    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.)
  7. Chris Barber 2012-08-08

    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
  8. Chris Barber 2012-08-08

    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.

JSON Source