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.
1swfobject.registerObject("clippy.orientation_event_snippet", "9");
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17// Capture the orientation event of the parent window.
18Sfdc.canvas.client.subscribe(sr.client,
19 {name : 'canvas.orientation',
20 onData : function (event) {
21 console.log("Parent's orientation: " + event.orientation +
22 "Canvas app height: " + event.clientHeight +
23 "Canvas app width: " + event. clientWidth);
24 }} );
25});
26