Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

create sliding to left effect beween two windows

$
0
0

i am working on creating sliding effect while going from first window to second i want to click a button on first window, which will slide the first window to left and simultaneously move the second window towards the main view where we can operate with it, when hit the back button it shoudl take me back to the first window i am trying following code, on andorid, titanium build: 3.1.3.20

var win = Ti.UI.createWindow({
    top: 0,
    left: 0,
    width: 320,
    height: 480,
    backgroundColor:"#00BFFF",
});
win.open();
 
var Questions = Titanium.UI.createButton({
    top: '50',
    height:'42dp',
    width:'150dp',
    id:"Questions", //This is a custom property
});
Questions.addEventListener("click", function(e){
    alert(e.source.id + " fired a " + e.type + " event");
     var eventWin = Ti.UI.createWindow({
         url:'win2.js',
        navBarHidden: true, 
         backgroundColor:'#FFF',
        _parent:Ti.UI.currentWindow,
        modal:true
 
    });
        var anim1 = Ti.UI.createAnimation({
        left: -320,
        duration: 1000
    });
    var anim2 = Ti.UI.createAnimation({
        left: 0,
        duration: 1000
    }); 
 
    win.animate(anim1);
    eventWin.animate(anim2);
    eventWin.open(anim2);
 
});
 
win.add(Questions);
win.open();
and win2.js
var win2 = Ti.UI.createWindow({
    top: 0,
    left: 320,
    width: 320,
    height: 480,
    backgroundColor:"#00FFBF",
});
win2.open();
what should i do

i have refered this code from

http://stackoverflow.com/questions/11135606/titanium-how-to-transition-slide-left-right-or-up-down-between-2-windows this works fine if i have two windows in the same page of code as shown below but iwant to maintain two different pages of code for better management

var win1 = Ti.UI.createWindow({
    top: 0,
    left: 0,
    width: 320,
    height: 480
});
 
var win2 = Ti.UI.createWindow({
    top: 0,
    left: 320,
    width: 320,
    height: 480
});
 
win1.addEventListener('swipe', function(){
    var anim1 = Ti.UI.createAnimation({
        left: -320,
        duration: 1000
    });
    var anim2 = Ti.UI.createAnimation({
        left: 0,
        duration: 1000
    });
    win1.animate(anim1);
    win2.animate(anim2);
});
please provide complete solution with code and explanation

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>