Handling Orientation Changes in Your Canvas App
The orientation event
enables you to handle changes in orientation when your canvas app
appears on a mobile device. After your canvas app subscribes to the
event, the event fires whenever the parent window fires a window.orientation event. The event returns
a payload that contains these values.
Value | Description |
---|---|
clientHeight | The height of the app in pixels, specific to the device on which the canvas app renders |
clientWidth | The width of the canvas app in pixels, specific to the device on which the canvas app renders |
orientation | Contains one of these values.
|
The following code example shows how to subscribe to the orientation event.
// Capture the orientation event of the parent window.
Sfdc.canvas.client.subscribe(sr.client,
{name : 'canvas.orientation',
onData : function (event) {
console.log("Parent's orientation: " + event.orientation +
"Canvas app height: " + event.clientHeight +
"Canvas app width: " + event. clientWidth);
}} );
});