Newer Version Available
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.
1// Capture the orientation event of the parent window.
2Sfdc.canvas.client.subscribe(sr.client,
3 {name : 'canvas.orientation',
4 onData : function (event) {
5 console.log("Parent's orientation: " + event.orientation +
6 "Canvas app height: " + event.clientHeight +
7 "Canvas app width: " + event. clientWidth);
8 }} );
9});