window.open(ANIMATION_TYPE) not working?

You must Login before you can answer or comment on any questions.

Hi guys, I've been trying to create a two-window system that contains a menu in the first window that, when clicked, opens a new window off-screen (linked to a .js file) and then slides it in from the right. After reading a bunch of tutorials it seems the best/easiest/cleanest way to do it is approximately this:

// vars
var SLIDE_DURATION = 1000;
var SCREEN_WIDTH = Ti.Platform.displayCaps.platformWidth;
var SLIDE_IN = Ti.UI.createAnimation({left:0, duration:SLIDE_DURATION});
var SLIDE_OUT = Ti.UI.createAnimation({left:-1 * SCREEN_WIDTH, duration:SLIDE_DURATION});
 
// main window
var main_win = Ti.UI.createWindow({
    title: 'Titanium: Demo Suite',
    layout: 'vertical',
    width: SCREEN_WIDTH
})
 
/* . . . add label, add menu, etc . . . */
 
// click event
menu_tbl.addEventListener('click', function(e){
    if (e.rowData.id){
 
        sub_win = Ti.UI.createWindow({
        layout: 'vertical',
        left: SCREEN_WIDTH,
        width: SCREEN_WIDTH,
        url: e.rowData.id + '.js', // dynamic JS file per page
        title: e.rowData.title // dynamic title per page
        });
 
    sub_win.open(SLIDE_IN);
    main_win.animate(SLIDE_OUT);
    }
});
 
/* . . . add label, menu, open main_win . . . */
But for some reason the main window, menu and everything works fine, the main window slides out fine, the sub window creates itself off-screen fine, but the sub_win.open(SLIDE_IN) animation never fires. Can anyone tell me where I'm going wrong?

setup: mobile / android emu / Titanium 2.1.2 (2012/08/16 17:16 9f63cf1) / Android Emu 4.0.2 / Titanium Studio, build: 2.1.1.201207271312

2 Answers

Accepted Answer

sub_win.open();
sub_win.animate(SLIDE_IN);

— answered 9 months ago by Alexander Bauer
answer permalink
3 Comments
  • yeah i'd worked out that works - but all the tutes and comments others have left around the net reckon that it should just work passing the animation straight into the open() function so I thought this way was just a workaround and not really the proper way to do it - is everyone else wrong?

    — commented 9 months ago by Daniel Napoleoni

  • its iOS only, therefore: yes, they are wrong.

    — commented 9 months ago by Alexander Bauer

  • haha rad - thanks mate!

    — commented 9 months ago by Daniel Napoleoni

i would look in JIRA, I know there have been some issues around animations not firing properly on Android

Your Answer

Think you can help? Login to answer this question!