Skip to content

Instantly share code, notes, and snippets.

I've lifted this from a project I'm working on, thought it might be interesting starting point for some sort of dynamic switching of styles with Alloy.

It's a hack, so please free to rip it apart.

  • Add the function to alloy.js

  • Add objects for "portrait" and "landscape" to your TSS (and leave defaults in there to be overridden, see the sample)

  • Call the function from your controller to a) init the view in case you have the device held in landscape when a window opens and b) within an event listener (remember to kill it)