Quantcast
Channel: .:zefanjas:.
Viewing all articles
Browse latest Browse all 95

EnyoJS and FirefoxOS screen orientation

$
0
0

Today I wanted to implement something in BibleZ NG that depends on the screen orientation (portrait or landscape) of a FxOS device.  Because I don’t use phonegap for this app (maybe later) here is my solution to handle it more EnyoJS-like. I’ve used enyo.Signals to listen for the orientation changed event and than send a custom event that my enyo kinds can listen to.

Put this in your main App.js file:

window.screen.onmozorientationchange = function () {
    enyo.Signals.send("onOrientationChange");
};

Listen to this custom event in your other enyo kinds:

{kind: "Signals", onOrientationChange: "handleOrientation"}

This is an example function to handle the different screen orientations:

handleOrientation: function (inSender, inEvent) {
    var orientation = screen.mozOrientation;
    if (orientation === "portrait-primary" || orientation === "portrait-secondary" ) {
        //do something
    }
    else if (orientation === "landscape-primary" || orientation === "landscape-secondary" ) {
        //do something
    }
}

via

Kommentar hinzufügen


Viewing all articles
Browse latest Browse all 95