SEARCH
0-9 A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Prev | Current Page 122 | Next

Richard Wagner

"Professional iPhone and iPod touch Programming: Building Applications for Mobile Safari"

innerWidth;
var orient = (currentWidth == 320) ? ???portrait??? : ???landscape???;
// do something useful here
document.getElementById(???mode??™).innerHTML = ???Current mode: ??? + orient;
}
setInterval(orientationChange, 400);



Ras sed nibh.



Donec semper lorem ac dolor ornare interdum. Praesent condimentum. Suspendisse
lacinia interdum augue. Nunc venenatis ipsum sed ligula. Aenean vitae lacus. Sed
sit amet neque. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices
posuere cubilia Curae; Duis laoreet lorem quis nulla. Curabitur enim erat, gravida
ac, posuere sed, nonummy in, tortor. Donec id orci id lectus convallis egestas.
Duis ut dui. Aliquam dignissim dictum metus.




addEventListener() is used to fire the orientationChange() function when the window is loaded.
The orientationChange() function is then called continuously using setInterval() at the end of
the script to poll the browser.
The orientationChange() function itself works by detecting changes in the innerWidth property of
the window . The function compares the innerWidth against its previously known value, which is stored
in the currentWidth variable. If the innerWidth has changed, then the currentWidth variable is
updated to the new innerWidth value and the orient variable is set with the current orientation.


Pages:
110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134