Note: This release is in preview. Features described here don’t become generally available until the latest general availability date that Salesforce announces for this release. Before then, and where features are noted as beta, pilot, or developer preview, we can’t guarantee general availability within any particular time frame or at all. Make your purchase decisions only on the basis of generally available products and features.
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});