<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>I am Dave Smith</title>
	
	<link>http://iamdavesmith.com</link>
	<description>Makin' them internets...</description>
	<lastBuildDate>Mon, 30 Jan 2012 14:12:02 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/IAmDaveSmith" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="iamdavesmith" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Swinging an element using CSS3 transitions (and a smidgen of jQuery!)</title>
		<link>http://iamdavesmith.com/swinging-an-element-using-css3-transitions-and-a-smidgen-of-jquery/</link>
		<comments>http://iamdavesmith.com/swinging-an-element-using-css3-transitions-and-a-smidgen-of-jquery/#comments</comments>
		<pubDate>Tue, 24 Jan 2012 21:59:15 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Web Tutorials]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[element]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[jquery]]></category>
		<category><![CDATA[swinging]]></category>

		<guid isPermaLink="false">http://iamdavesmith.com/?p=29</guid>
		<description><![CDATA[So, just before Christmas I was tasked with sprucing up a site for a corporate party. The site was designed around the idea of a party that had gotten.. slightly out of hand. It featured a drunk looking dude on a chandelier at the top of the page, so to add a little extra fun [...]]]></description>
			<content:encoded><![CDATA[<p>So, just before Christmas I was tasked with sprucing up a site for a corporate party. The site was designed around the idea of a party that had gotten.. slightly out of hand. It featured a drunk looking dude on a chandelier at the top of the page, so to add a little extra fun I decided to animate him swinging from left to right &#8211; and make it look like he was having a pretty sweet time.</p>
<p>This post will walk you through how to make an element swing using CSS3 and a little javascript &#8211; just like <a href="http://iamdavesmith.com/examples/swing.html" target="_new">in this example</a>.</p>
<p>I started by modifying the image so that the edge of the top of the &#8216;swing&#8217; was in the center of the image, and the swing started at a 45 degree angle &#8211; like so..</p>
<div id="attachment_38" class="wp-caption aligncenter" style="width: 210px"><a href="http://iamdavesmith.com/wp-content/uploads/2012/01/swing.png"><img class="size-full wp-image-38" title="swing" src="http://iamdavesmith.com/wp-content/uploads/2012/01/swing.png" style="border: 1px dotted #cccccc" alt="" width="200" height="200" /></a><p class="wp-caption-text">Fear my photoshop skills.</p></div>
<p>So, after we&#8217;ve done this, we need to set up our markup! It&#8217;s not exactly complicated&#8230;. infact, all you need is the div that you want to swing.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="html4strict" style="font-family:monospace;"><span style="color: #009900;">&lt;<span style="color: #000000; font-weight: bold;">div</span> <span style="color: #000066;">class</span><span style="color: #66cc66;">=</span><span style="color: #ff0000;">&quot;swing&quot;</span>&gt;&lt;<span style="color: #66cc66;">/</span><span style="color: #000000; font-weight: bold;">div</span>&gt;</span></pre></td></tr></table></div>

<p>Next up, we need to set up our CSS, as below.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
</pre></td><td class="code"><pre class="css" style="font-family:monospace;"><span style="color: #6666ff;">.swing</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span> <span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span> <span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000;">'swing.png'</span><span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-webkit-transition<span style="color: #00AA00;">:</span> all 1s ease-in-out<span style="color: #00AA00;">;</span>
	-moz-transition<span style="color: #00AA00;">:</span> all 1s ease-in-out<span style="color: #00AA00;">;</span>
	-o-transition<span style="color: #00AA00;">:</span> all 1s ease-in-out<span style="color: #00AA00;">;</span>
	-ms-transition<span style="color: #00AA00;">:</span> all 1s ease-in-out<span style="color: #00AA00;">;</span>
	transition<span style="color: #00AA00;">:</span> all 1s ease-in-out<span style="color: #00AA00;">;</span>
	-moz-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-webkit-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-o-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-ms-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
&nbsp;
.<span style="color: #000000; font-weight: bold;">right</span> <span style="color: #00AA00;">&#123;</span>
	-moz-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-90deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-webkit-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-90deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-o-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-90deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
	-ms-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>-90deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span></pre></td></tr></table></div>

<p>Sure, this looks like a lot of CSS for something relatively basic.. but since the CSS3 specification has not been ratified, we need to target the four main rendering engines specifically (Hence all the prefixs &#8211; <strong>moz</strong>, <strong>webkit</strong>, <strong>o</strong> and <strong>ms</strong>. </p>
<p>So &#8211; what does this CSS do? In the case of the below examples, I have replaced the relevant rendering engine prefix with an X.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">X-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>0deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></td></tr></table></div>

<p>This sets the rotation of our image to 0 degress &#8211; which is how it initially appears on the page.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">X-transform<span style="color: #00AA00;">:</span>rotate<span style="color: #00AA00;">&#40;</span>90deg<span style="color: #00AA00;">&#41;</span><span style="color: #00AA00;">;</span></pre></td></tr></table></div>

<p>This sets the rotation of our image to.. you guessed it.. 90 degrees &#8211; the second state we need for our swinging motion.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="css" style="font-family:monospace;">X-transition<span style="color: #00AA00;">:</span> all 1s ease-in-out<span style="color: #00AA00;">;</span></pre></td></tr></table></div>

<p>This tells our browser(s) to set an animation that lasts 1 second and has easing in and out, on our specified element.</p>
<p>Then all we have to do switch between our 2 classes every second. this is easily achievable with jQuery, using the following code:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="javascript" style="font-family:monospace;">   $<span style="color: #009900;">&#40;</span>document<span style="color: #009900;">&#41;</span>.<span style="color: #660066;">ready</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
      <span style="color: #003366; font-weight: bold;">function</span> swing<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'.swing'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">toggleClass</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'right'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
         setTimeout<span style="color: #009900;">&#40;</span>swing<span style="color: #339933;">,</span> <span style="color: #CC0000;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      swing<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

<p>This piece of code creates a function called &#8216;<strong>swing</strong>&#8216; &#8211; which basically toggles the class of &#8216;<strong>right</strong>&#8216; on our element. As soon as it&#8217;s toggled, it sets a timeout to call the function again in a second. We call the swing function as soon as the page has loaded, and the process of toggling every second starts. Rinse. Repeat. Win!</p>
<p>And that&#8217;s it!</p>
<p>You can have a look at it in action <a href="http://iamdavesmith.com/examples/swing.html" target="_new">here</a>. Exciting stuff, huh?</p>
<p><em>Thoughts? Comments? Criticisms? Leave a comment below, or contact me on Twitter &#8211; <a href="http://twitter.com/smyther" target="_newwwwwwindow">@smyther</a></em></p>
]]></content:encoded>
			<wfw:commentRss>http://iamdavesmith.com/swinging-an-element-using-css3-transitions-and-a-smidgen-of-jquery/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Real life begins here</title>
		<link>http://iamdavesmith.com/real-life-begins-here/</link>
		<comments>http://iamdavesmith.com/real-life-begins-here/#comments</comments>
		<pubDate>Sun, 01 May 2011 00:18:08 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[Life]]></category>

		<guid isPermaLink="false">http://iamdavesmith.com/?p=1</guid>
		<description><![CDATA[Hello, internet. It&#8217;s been a while. The last time I wrote a blog, I was just about to finish uni and start looking for a job. Well, I finished uni and achieved a 2:1 in Digital Forensics. I had a good 3 years, but after finishing I decided that I&#8217;d rather not work in that [...]]]></description>
			<content:encoded><![CDATA[<p>Hello, internet. It&#8217;s been a while. The last time I wrote a blog, I was just about to finish uni and start looking for a job.</p>
<p>Well, I finished uni and achieved a 2:1 in Digital Forensics. I had a good 3 years, but after finishing I decided that I&#8217;d rather not work in that field&#8230; Although I was good at it (at least, I think I was?!), I just didn&#8217;t feel like it was something I wanted to do for the next 2 years, let alone the rest of my life.</p>
<p><a target="_blank" href="http://www.specialness.net">Janet</a> and myself moved down to Coventry and in with my parents. Janet got a job quickly, and was working 40 hrs a week to get our &#8216;move out of my parents house&#8217; fund going.. Me? It wasn&#8217;t going so well&#8230; I bummed around for a while. I looked for jobs at various companies and even looked into jobs in Digital Forensics just so i&#8217;d be earning some money. While I was bumming around my time was interspersed with playing xbox, applying for jobs and brushing up on my PHP and CSS which was the field I really wanted to work in. This kinda stuff had always been a hobby of mine (and as a youngster, a source of money)</p>
<p>After a worrying amount of time, I was still jobless. Then a friend of mine called me. He worked at a company who needed a freelance PHP/CSS developer to go work on some stuff for a week or two. I stayed there for 8 months, before I was offered a full-time job, which I jumped at. So yeah, I&#8217;m now a front (and a little bit of a back) end developer at McCann Erickson Birmingham. Been there about 18 months now&#8230; And it&#8217;s a lot of fun. I&#8217;ve had the chance to work with high profile clients such as Harley Davidson, Lotus Cars, Vauxhall and several others.</p>
<p>It&#8217;s a job &#8211; quite a good one. The people are generally nice, and the atmosphere is pretty good. A lot of the time it doesn&#8217;t feel like work, but the rest of the time&#8230; It does (surprise!). Gotta take the rough with the smooth I guess. Anyway, after a few months of working there Janet and I moved into our own place. Janet had finished working by now and started to study for an Early Years Professional Status&#8230; thing. Basically, if she got it it meant she&#8217;d be able to manage nurseries (I think?) , and since she is a big fan of kids this was right up her alley.</p>
<p>What happened next was the single most scary and exciting 9 months of my life (so far?)&#8230;. But that&#8217;s a whole other post.</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://iamdavesmith.com/real-life-begins-here/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Hang on…</title>
		<link>http://iamdavesmith.com/hang-on/</link>
		<comments>http://iamdavesmith.com/hang-on/#comments</comments>
		<pubDate>Sat, 30 Apr 2011 21:15:24 +0000</pubDate>
		<dc:creator>Dave</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://iamdavesmith.com/archives/12</guid>
		<description><![CDATA[There&#8217;ll be something here VERY soon. That&#8217;s a promise. Stay tuned, kids.]]></description>
			<content:encoded><![CDATA[<p>There&#8217;ll be something here VERY soon. That&#8217;s a promise. Stay tuned, kids.</p>
]]></content:encoded>
			<wfw:commentRss>http://iamdavesmith.com/hang-on/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

