<?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>Azavea Labs &#187; Effects</title>
	<atom:link href="http://www.azavea.com/blogs/labs/tag/effects/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.azavea.com/blogs/labs</link>
	<description>Insight on what our engineers are doing</description>
	<lastBuildDate>Mon, 06 Feb 2012 22:32:15 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
<xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" />
		<item>
		<title>Using Ext.js Fx.slideIn For Image Rotating</title>
		<link>http://www.azavea.com/blogs/labs/2009/06/using-extjs-fxslidein-for-image-rotating/</link>
		<comments>http://www.azavea.com/blogs/labs/2009/06/using-extjs-fxslidein-for-image-rotating/#comments</comments>
		<pubDate>Thu, 18 Jun 2009 10:12:13 +0000</pubDate>
		<dc:creator>Carissa Brittain</dc:creator>
				<category><![CDATA[Posts]]></category>
		<category><![CDATA[Effects]]></category>
		<category><![CDATA[ExtJS]]></category>
		<category><![CDATA[tips]]></category>

		<guid isPermaLink="false">http://www.azavea.com/blogs/labs/?p=131</guid>
		<description><![CDATA[PhillyHistory.org's homepage will be getting a face lift soon, and I've turned to Ext.js and their built-in effects library to do some image sliding. The first thing I learned from the documentation was that the Fx methods applied to anything that was could also be an Ext.Element. Neat!]]></description>
			<content:encoded><![CDATA[<p><a title="PhillyHistory" href="http://www.phillyhistory.org/PhotoArchive/Home.aspx" target="_blank">PhillyHistory.org&#8217;</a>s homepage will be getting a face lift soon, and I&#8217;ve turned to <a title="ExtJS" href="http://extjs.com/">Ext.js</a> and their built-in effects library to do some image sliding. The first thing I learned from the <a title="Ext.Fx Documentation" href="http://extjs.com/deploy/dev/docs/?class=Ext.Fx" target="_blank">documentation</a> was that the Fx methods applied to anything that was could also be an Ext.Element. Neat! Now to find some <a title="Ext Official Examples" href="http://extjs.com/deploy/dev/examples/samples.html" target="_blank" class="broken_link" rel="nofollow">examples</a>&#8230;. no examples? What about forum entries&#8230; hm.. very few and with little information I could use. Let&#8217;s try a general web search&#8230; again, little I could use. There doesn&#8217;t seem to be much written about this useful little <a title="In the corner..." href="http://images.google.com/images?q=room+corner" target="_blank">corner</a> of Ext.js.</p>
<p>After a few hours of poking, <a title="yum..." href="http://www.exploratorium.edu/cooking/candy/recipe-taffy.html" target="_blank">pulling</a>, swapping and switching, I finally had a bit of code that does what I want: take a few photos and <a title="Slides in Space!" href="http://www.flickr.com/photos/neatocoolville/107332568/" target="_blank">slide</a> them into view one at a time, leaving the previous photo visible as a background while the next slides in. While creating this <a title="Survey says..." href="http://stackoverflow.com/questions/952194/should-code-be-short-concise" target="_blank">concise</a> bit of magic, I wound up only using one of the methods that Ext.Fx provides: the slideIn method. Here it is:</p>
<p>&lt;myDiv&gt;.syncFx().slideIn(&#8216;l&#8217;, {duration:.5});</p>
<p>The slideIn method&#8217;s attributes couldn&#8217;t be simpler: l is for left, so the slide starts on the left;  duration is how long it takes to slide, in seconds. The background for the sliding-in image is white by default, or whatever the <a title="All about backgrounds" href="http://www.tutorialhero.com/tutorial-52-css_background_image_guide.php" target="_blank">background of your element</a> is set to. I wanted the previous photo to look like it was sticking around while the next was sliding in, so my first instinct was to dynamically set the background image before sliding. This would have worked fine, except that my images are being re-sized to fit into a static-sized div. Backgrounds don&#8217;t re-size like a nested image will, so I created a background image in the same div, set the z-index so that it&#8217;s lower than the div I&#8217;m sliding and dynamically set that instead. <a title="That&#039;s what they said." href="http://www.wisdomquotes.com/cat_success.html" target="_self" class="broken_link" rel="nofollow">Success</a>! I now have a sliding image that looks like the next image slides over the previous one.</p>
<p>Here&#8217;s a bit of psudeocode with the important bits to get you started:</p>
<p>&lt;div id=&#8221;RotationWrapper&#8221;&gt;<br />
&lt;img id=&#8221;Background&#8221;  style=&#8221;z-index:-1;position:absolute;height:200px;width:400px;&#8221;/&gt;<br />
&lt;img id=&#8221;Foreground&#8221; style=&#8221;height:200px;width:400px;&#8221; src=&#8221;first image&#8221;/&gt;<br />
&lt;/div&gt;</p>
<p>&lt;script&gt;<br />
setInterval(function() {<br />
Background.src = Foreground.src;<br />
Foreground.src = &lt;new image&gt;<br />
Foreground.syncFx().slideIn(&#8216;l&#8217;, {duration:.5});<br />
}, 5000)<br />
&lt;/script&gt;</p>
<p>One bit of oddness to keep in mind though. You have to set the sliding div&#8217;s new image BEFORE you slide it, otherwise the same image will slide in, then <a title="Eeeeviiiil!" href="http://en.wikipedia.org/wiki/Blink_element" target="_blank">blink</a> to the new image when it&#8217;s done. I don&#8217;t know why the image switch waits till after the slide even though I did it first, but it does. Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.azavea.com/blogs/labs/2009/06/using-extjs-fxslidein-for-image-rotating/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

