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

Alloy: Responding to orientation change in current view

$
0
0

Hi, I'm trying to build a nice way to respond to orientation changes. Here is what I implemented:

Alloy.Globals.isPortrait = true;
Alloy.Globals.isLandscape = false;
 
Ti.Gesture.addEventListener('orientationchange', function(e) {
    // here you react to the startup orientation
    if (e.orientation === Ti.UI.LANDSCAPE_LEFT || e.orientation === Ti.UI.LANDSCAPE_RIGHT){
        Alloy.Globals.isPortrait = false;
        Alloy.Globals.isLandscape = true;
 
    }else{
        Alloy.Globals.isPortrait = true;
        Alloy.Globals.isLandscape = false;
    }
    Ti.API.info("[ORIENTATION] Change, Portrait="+Alloy.Globals.isPortrait+" Landscape="+Alloy.Globals.isLandscape);
});
TSS:
"#header":{
    height:"10%",
    layout:"horizontal",
    backgroundColor: Alloy.Globals.BaseColor
}
 
"#header[if=Alloy.Globals.isLandscape]":{
    height:"30%",
    layout:"horizontal",
    backgroundColor: Alloy.Globals.BaseColor
}
This works for any screen painted after the gesture change, but I can't seem to get the current screen to re-apply the TSS. Any tips?

Viewing all articles
Browse latest Browse all 8068

Trending Articles



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