<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DaveOnCode &#187; display orientation</title>
	<atom:link href="http://www.daveoncode.com/tag/display-orientation/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.daveoncode.com</link>
	<description>Objective C, iOS and more programming stuff</description>
	<lastBuildDate>Mon, 19 Dec 2011 12:11:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Detecting display&#8217;s orientation change on mobile devices with accelerometer: a platform indipendent approach (n95, i900, iPhone&#8230;) with javascript</title>
		<link>http://www.daveoncode.com/2008/12/15/detecting-displays-orientation-change-on-mobile-devices-with-accelerometer-a-platform-indipendent-approach-n95-i900-iphone-with-javascript/</link>
		<comments>http://www.daveoncode.com/2008/12/15/detecting-displays-orientation-change-on-mobile-devices-with-accelerometer-a-platform-indipendent-approach-n95-i900-iphone-with-javascript/#comments</comments>
		<pubDate>Mon, 15 Dec 2008 13:55:59 +0000</pubDate>
		<dc:creator>Davide Zanotti</dc:creator>
				<category><![CDATA[mobile]]></category>
		<category><![CDATA[accelerometer]]></category>
		<category><![CDATA[display orientation]]></category>
		<category><![CDATA[i900]]></category>
		<category><![CDATA[iphone]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[n95]]></category>
		<category><![CDATA[opera mobile]]></category>
		<category><![CDATA[samsung omnia]]></category>
		<category><![CDATA[smartphone]]></category>

		<guid isPermaLink="false">http://daveoncode.wordpress.com/?p=144</guid>
		<description><![CDATA[As I wrote, I bought a Samsung i900 Omnia (which as Nokia n95, iPhone and other modern cool mobile phones, has an accelerometer), as a web developer one of the first things that I had in mind was &#8220;how can I detect the orientation change (landscape or portrait mode) with javascript or actionscript?&#8221;. The first [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2008/12/15/detecting-displays-orientation-change-on-mobile-devices-with-accelerometer-a-platform-indipendent-approach-n95-i900-iphone-with-javascript/' addthis:title='Detecting display&#8217;s orientation change on mobile devices with accelerometer: a platform indipendent approach (n95, i900, iPhone&#8230;) with javascript ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></description>
			<content:encoded><![CDATA[<p>As I wrote, I bought a Samsung i900 Omnia (which as Nokia n95, iPhone and other modern cool mobile phones, has an accelerometer), as a web developer one of the first things that I had in mind was &#8220;how can I detect the orientation change (landscape or portrait mode) with javascript or actionscript?&#8221;. The first things I thought was:</p>
<ol>
<li>If the display changes its orientation mode, then the screen width and height must will updated with the new size</li>
<li>If the screen width is smaller than screen height, the device must be in &#8220;portrait&#8221; mode</li>
<li>Vice versa, if the screen width is bigger than screen height, the device must be in &#8220;landscape&#8221; mode</li>
<li>The only thing I need is to check the value of screen size and define the orientation mode according to the point 2 and 3</li>
</ol>
<p>And, as I can see, my deductions was right! I<span class="__mozilla-findbar-search" style="background-color:yellow;color:black;display:inline;font-size:inherit;padding:0;"></span> realized a small javascript script, which by using <strong><em>setInterval()</em></strong> function and controlling <strong><em>screen.width</em></strong> and <strong><em>screen.heigth</em></strong> deduces the device orientation mode. Anyway it works actually only with Opera mobile 9.5 (tested only on Samsung Omnia), Internet Explorer Mobile seems unable to interpreting some javascript functions.</p>
<p>This is a piece of my code (the main logic behind):</p>
<pre>if (screen.width != width &amp;&amp; screen.height != height) {
    width = screen.width;
    height = screen.height;
    mode = width &gt; height ? "landscape" : "portrait";
}</pre>
<p>If you would like to test my script go to http://daveoncode.site90.net</p>
<p>Let me know, thanks ;-)</p>
<p>ps. as soon I will understand about flash capability on my device I will try to implement a custom Actionscript event for the orientation&#8230; something like DisplayEvent.DISPLAY_MODE_CHANGE</p>
<p>UPDATE: if you are unable to load  http://daveoncode.site90.net try http://andreacfm.com/dave/ (I have to thanks my friend Andrea Campolonghi for the space)</p>
<p>UPDATE 2: the script works even on Blackberry&#8217;s browser (as someone told me) :)</p>
<p>UPDATE 3: it works even on HTC devices (at this point the only problem is internet explorer mobile&#8230; I will investigate!)</p>
<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.daveoncode.com/2008/12/15/detecting-displays-orientation-change-on-mobile-devices-with-accelerometer-a-platform-indipendent-approach-n95-i900-iphone-with-javascript/' addthis:title='Detecting display&#8217;s orientation change on mobile devices with accelerometer: a platform indipendent approach (n95, i900, iPhone&#8230;) with javascript ' ><a class="addthis_button_preferred_1"></a><a class="addthis_button_preferred_2"></a><a class="addthis_button_preferred_3"></a><a class="addthis_button_preferred_4"></a><a class="addthis_button_compact"></a></div>]]></content:encoded>
			<wfw:commentRss>http://www.daveoncode.com/2008/12/15/detecting-displays-orientation-change-on-mobile-devices-with-accelerometer-a-platform-indipendent-approach-n95-i900-iphone-with-javascript/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>

