orientationchange eventversion added: 1.0
Description: Device portrait/landscape orientation event
-
jQuery( window ).on( "orientationchange", function( event ) { ... } )
Additional properties on the event object:
-
orientationType: StringThe new orientation of the device. Possible values are
"portrait"
and"landscape"
.
-
The jQuery Mobile orientationchange
event triggers when a device orientation changes, either by turning the device vertically or horizontally. When bound to this event the callback function has the event object. The event object contains an orientation
property equal to either "portrait"
or "landscape"
.
Note that we bind to the browser's resize event when orientationchange
is not natively supported or if $.mobile.orientationChangeEnabled
is set to false
.
orientationchange timing
The timing of the orientationchange
event with relation to the change of the client height and width is different between browsers, though the current implementation will give you the correct value for event.orientation
derived from window.orientation
. This means that if your bindings are dependent on the height and width values you may want to disable orientationChange
altogether with $.mobile.orientationChangeEnabled = false
to let the fallback resize code trigger your bindings.
Example:
Visit this from your orientation-enabled device to see it in action!
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
|