Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Mobile: Something is not right with the animation of currentWindow.close() method

Hi Guys,

This has been troubling me for a while so please help if you can!

With the following code:

var winNew = Ti.UI.createWindow({title:'Test Window', ...(other properties) });
Ti.UI.currentTab.open(winNew);

I am creating a new window and opening it by the currentTab.

However, if I run the following closing method, the animation is not as expected as comparing to native iphone method.

var win = Ti.UI.currentWindow;   // This = winNew

win.close();

What was supposed happen is that by closing the current window, the window will perform a animation that shifts itself to the right while the previous window enters the scenes from the left.

However this is not what's happening with when coding in Titanium. The win.close() simply fades out (flash to black) the current window while the previous window enters from the left.

Anyone have any idea on this?? Please help! thanks in advance!!

— asked May 24th 2010 by William Xue
  • close()
  • currenttab
  • currentwindow
  • iphone
  • mobile
  • titanium
0 Comments

6 Answers

  • You need to add the transition you want the window to close with:

    
    win.close({transition:Titanium.UI.iPhone.AnimationStyle.CURL_UP});
    
    — answered May 24th 2010 by Dan Tamas
    permalink
    0 Comments
  • Struggeling with the exact same problem as the topics starter for 2 days now. The window itself does seem to do the right animation (flip to right or left), but the Navigation Bar at the top doesn't seem to do the desired effect. It just stays still and changes, not animating…

    Tried Tamas' suggestion, but then i get an error:

    Result of expression 'Titanium.UI.iPhone.AnimationStyle' [undefined] is not an object.";
    

    and…

    close({animated:true})
    

    … also does not seem to work for the Navigation Bar

    I'm using a custom barImage and a custom backbutton at the navigation bar. Maybe that's the problem?

    edit: you can see the problem in KitchenSink: Base UI > Window NavBar > Back button BG. Then use the back button and you'll see the "NavBar" is not animating properly. Seems like a bug then?

    — answered January 19th 2011 by Jordy van den Aardweg
    permalink
    2 Comments
    • Yes, does seem like a bug. Hope they get this fixed soon.

      — commented January 26th 2011 by Marshall Jones
    • Get rid of the custom back button. If you open in the current tab, it generates one to the previous window automatically, and does the reverse animation used to open it.

      — commented February 3rd 2011 by Josh Lewis
  • You get something better, but still not perfect, by using

    win.tab.close(win)
    

    instead of:

    win.close()
    
    — answered February 3rd 2011 by Mario Capocaccia
    permalink
    0 Comments
  • Thanks for your reply Tamas.

    What I wannted was sort of effect that is similiar to hitting the Back button on a window's left navBar.

    — answered May 24th 2010 by William Xue
    permalink
    0 Comments
  • Had same issue, Ti.UI.currentTab.close(win, {animated: true}); worked for me

    — answered January 14th 2013 by Christopher Stea
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.