<?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>Superted</title>
	<atom:link href="http://superted.me/feed" rel="self" type="application/rss+xml" />
	<link>http://superted.me</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Mon, 20 Feb 2012 12:26:27 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Site redesign</title>
		<link>http://superted.me/site-redesign</link>
		<comments>http://superted.me/site-redesign#comments</comments>
		<pubDate>Mon, 20 Feb 2012 12:26:27 +0000</pubDate>
		<dc:creator>ted</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://superted.me/?p=135</guid>
		<description><![CDATA[So I decided to redesign my blog and add my portfolio to superted.me (it used to be at tedlittledale.co.uk) as I now use Superted Ltd as my trading name.
I&#8217;ve been using this great full screen color picker, http://color.aurlien.net/, for a while now whenever I&#8217;ve needed a bit of inspiration to pick a color for something. [...]]]></description>
			<content:encoded><![CDATA[<p>So I decided to redesign my blog and add my portfolio to superted.me (it used to be at tedlittledale.co.uk) as I now use Superted Ltd as my trading name.<br />
I&#8217;ve been using this great full screen color picker, http://color.aurlien.net/, for a while now whenever I&#8217;ve needed a bit of inspiration to pick a color for something. I really like the mouse effect they use and so used that as the inspiration for the redesign. I also really like Futura so wanted to use some nice big text.</p>
]]></content:encoded>
			<wfw:commentRss>http://superted.me/site-redesign/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Twitter widget</title>
		<link>http://superted.me/twitter-widget</link>
		<comments>http://superted.me/twitter-widget#comments</comments>
		<pubDate>Thu, 02 Jun 2011 16:27:49 +0000</pubDate>
		<dc:creator>ted</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://superted.me/?p=100</guid>
		<description><![CDATA[I&#8217;ve finally had some downtime recently so I&#8217;ve been spending time redesigning my portfolio site. I wanted to add a twitter widget that animated between recent tweets using a bit of css3 transition magic. This is what I came up with (I&#8217;ve sped up the interval time for the demo):

Your browser does not support iframes.

In [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve finally had some downtime recently so I&#8217;ve been spending time redesigning my portfolio site. I wanted to add a twitter widget that animated between recent tweets using a bit of css3 transition magic. <a href="/twitter-feed/" target="_blank">This</a> is what I came up with (I&#8217;ve sped up the interval time for the demo):</p>
<p><iframe src="/twitter-feed/" width="100%" height="300"></p>
<p>Your browser does not support iframes.</p>
<p></iframe></p>
<p>In terms of markup, the tweets are generated as a simple unordered list using php.</p>
<p>The javascript was pretty simple really. First some empty divs are added to the containing div to act as a mask. These are sized and positioned so that they cover the whole tweet when the &#8216;right&#8217; css property of each div is set to 0. They are also given an incremental transition delay so that the top div animates first and the rest follow.</p>
<p>When the tweet transitions the &#8216;right&#8217; property is set to 0 hideing the tweet. The current tweet is then swapped for the next before the &#8216;right&#8217; property is set again to the width of the tweet, thus revealing the next tweet. The animation is handled by the css.<br />
<h3>The JS</h3>
<pre class="brush: js">
/**
	 * Add markup to twitter div for animation
	 * @private
	 * @param {jQueryObject} section The parent element
	 * @returns Describe what it returns
	 * @type String|Object|Array|Boolean|Number
	 */
	var initTwitterAnimation = function(section){
		var current = section.find(&#039;li:visible&#039;), top = 0;
		current.parent().wrap(&#039;&lt;div class=&quot;shutterWrap&quot;&gt;&lt;/div&gt;&#039;);
		var wrap = 	section.find(&#039;.shutterWrap&#039;),
					shutterHeight = Math.ceil(current.outerHeight()/10),
					shutterWidth = current.outerWidth();
		for(var i = 0; i &lt; 10; i++){
			wrap.css(&#039;position&#039;,&#039;relative&#039;).append(&#039;&lt;div class=&quot;shutter&quot;&gt;&lt;/div&gt;&#039;);
		}
		section.find(&#039;.shutter&#039;).each(function(i){
			$(this).css({
				height : shutterHeight+&#039;px&#039;,
				position : &#039;absolute&#039;,
				top : top + &#039;px&#039;,
				width : &#039;100%&#039;,
				background : &#039;#fff&#039;,
				right:-shutterWidth+&#039;px&#039;
			});
			this.style.webkitTransitionDelay = i*(0.05)+&#039;s&#039;;
			this.style.MozTransitionDelay = i*(0.05)+&#039;s&#039;;
			top += shutterHeight;
		});
		setTimeout(function() {
			animateTwitter(section, shutterWidth);
		}, 1000);
	};//initTwitterAnimation

	var animateTwitter = function(section, shutterWidth){
		var hiding = true;
		var current = section.find(&#039;li:visible&#039;), top = 0, next;
		var next = current.next();
		if(next.length === 0){
			next = section.find(&#039;li:first&#039;);
		}
		var goToNext = function(){
			if(hiding){
				current.hide();
				next.show();
				shutterHeight = Math.ceil(next.outerHeight()/10);
				section.find(&#039;.shutter&#039;).each(function(i){
					$(this).css({
						height : shutterHeight+&#039;px&#039;,
						top : top + &#039;px&#039;
					});
					top += shutterHeight;
				});
				section.find(&#039;.shutter&#039;).each(function(){
					$(this).css({
						right : -shutterWidth+&#039;px&#039;
					});
				});
				hiding = false;
			}
		}
		section.find(&#039;.shutter:last&#039;)[0].addEventListener(&#039;webkitTransitionEnd&#039;, goToNext, true);
		section.find(&#039;.shutter:last&#039;)[0].addEventListener(&#039;transitionend&#039;, goToNext, true);
		section.find(&#039;.shutter&#039;).each(function(){
			$(this).css({
				right:0+&#039;px&#039;
			});
		});
		setTimeout(function() {
			animateTwitter(section, shutterWidth);
		}, 2000);
	};//animateTwitter
</pre>
<h3>The CSS</h3>
<pre class="brush: css">
/* twitter */
.twitter{/*container*/
	width:240px;
	padding: 10px;
	float: left;
	overflow: hidden;
}
.twitter li{/*each tweet is an li*/
	list-style: none;
	display: none;
	background-color: #3 3ccff;
	background-image:-webkit-gradient(radial, 50% 50%, 1, 50% 50%, 170, from(#33ccff), to(rgba(51,204,255,0.4)));
	background-image:-moz-radial-gradient(50% 50% 90deg,ellipse closest-side, #33ccff, rgba(51,204,255,0.5));
	color: #fff;
	padding: 10px;
	-webkit-border-radius: 10px;
	   -moz-border-radius: 10px;
	        border-radius: 10px;
	font-size: 18px;
}
.twitter li:first-child{/*show the first tweet by default*/
	display: block;
}
.shutter{/*add the transition to the shutter divs*/
	-webkit-transition: right 0.2s ease-in;
	-moz-transition: right 0.2s ease-in;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://superted.me/twitter-widget/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>iAd &#8216;SDK&#8217;</title>
		<link>http://superted.me/iad-sdk</link>
		<comments>http://superted.me/iad-sdk#comments</comments>
		<pubDate>Tue, 29 Jun 2010 16:18:09 +0000</pubDate>
		<dc:creator>ted</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://superted.me/?p=88</guid>
		<description><![CDATA[When Apple first announced their iAd platform they mentioned that they would be releasing an SDK to allow developers to build these ads. This was intriguing as I don&#8217;t know any developers who would use an SDK to create HTML/Javascript applications, as opposed to using a text editor such as Textmate. I was a bit [...]]]></description>
			<content:encoded><![CDATA[<p>When Apple first announced their iAd platform they mentioned that they would be releasing an SDK to allow developers to build these ads. This was intriguing as I don&#8217;t know any developers who would use an SDK to create HTML/Javascript applications, as opposed to using a text editor such as Textmate. I was a bit concerned that Apple would restrict iAd development to some sort of WYSIWYG built into the XCode application.</p>
<p><img src="http://superted.me/wp-content/uploads/2010/06/Screen-shot-2010-06-29-at-09.23.47.png" alt="" title="Screen shot 2010-06-29 at 09.23.47" width="384" height="115" class="alignnone size-full wp-image-90" style="float:left; margin-right:10px" /></p>
<p>So anyway, when Apple officially announced iPhone 4 they released iAd JS, which was available for download as a dmg from the iPhone developer center (paid developer login required I think).</p>
<p>You have to install this using the mac installer but is essentially just unzips a directory into the root developer folder:</p>
<p><img src="http://superted.me/wp-content/uploads/2010/06/Screen-shot-2010-06-29-at-16.33.58.png" alt="" title="Screen shot 2010-06-29 at 16.33.58" width="394" height="627" class="alignnone size-full wp-image-94" style="float:left; margin-right:10px" /></p>
<p>The iAdTester.app is an iphone app that you install via itunes and allows you to test your iAds on an iPhone.</p>
<p>The tests folder container examples of all the widgets, controls etc that can Apple has provided for used within iAds. E.g. CarouselView is the the 3D carousel which they used for the toy-story iAd which I recreated (I haven&#8217;t dug into their code so see how they&#8217;ve implemented it yet). Most of the examples show how to create controls that look and behave like native iPhone controls.</p>
<p>So as you can see this isn&#8217;t really an SDK but a javascript library to help in the process of creating iAds. I think this is a good approach as it allows developers to create interfaces with familiar controls but also gives them freedom to use their imagination to create anything that html5/css3 allows.</p>
<p>I&#8217;ll save the deployment and testing process for another post but it is fairly simple and painless</p>
]]></content:encoded>
			<wfw:commentRss>http://superted.me/iad-sdk/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Shattering Images</title>
		<link>http://superted.me/shattering-images</link>
		<comments>http://superted.me/shattering-images#comments</comments>
		<pubDate>Tue, 27 Apr 2010 22:25:50 +0000</pubDate>
		<dc:creator>ted</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://superted.me/?p=81</guid>
		<description><![CDATA[I&#8217;ve been messing around with css3 transitions and seeing how many can run simultaneously without noticeable performance lag. So, inspired by this cool bit of canvas wizardry I thought I&#8217;d create some image shattering effects to test how well css transitions could cope.
Below are two videos of the results. The first is doing simultaneously animating [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve been messing around with css3 transitions and seeing how many can run simultaneously without noticeable performance lag. So, inspired by this <a href="http://www.craftymind.com/2010/04/20/blowing-up-html5-video-and-mapping-it-into-3d-space/">cool bit of canvas wizardry</a> I thought I&#8217;d create some image shattering effects to test how well css transitions could cope.</p>
<p>Below are two videos of the results. The first is doing simultaneously animating 25 elements in 3d and cope fine without any lag at all. The second is animating 256 elements and although there is some lag after clicking the image, the animation itself is remarkably smooth. You can view the first for yourself at <a href="http://superted.me/stuff/shatter.html">http://superted.me/stuff/shatter.html</a> on any webkit browser although the 3d effect only works on the iphone.</p>
<div style="float:left; width:300px;height:477;margin-right:10px"><object width="300" height="477"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11278441&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=11278441&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="300" height="477"></embed></object></div>
<p><object width="300" height="477"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11278565&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=11278565&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="300" height="477"></embed></object></p>
<p>There were three key steps in creating this effect. The first was a function to create the image, which is essentially a collection of divs with the same background image positioned to look like a single image:</p>
<pre class="brush: js">
shatter.createMozaic = function(uid, first){
		var w = 320 / PANELS;
		var h = w;
		for(var i = 0, l = PANELS; i &lt; l; i++){
			for(var j = 0; j &lt; PANELS; j++){
				//create a div for each panel
				var div = document.createElement(&#039;div&#039;);
				div.className = &#039;imgSection &#039;+uid;
				//offset each panel
				div.style.top = (j * h) + 50 + &#039;px&#039;;
				div.style.left = (i * w) + &#039;px&#039;;
				div.style.width = w + &#039;px&#039;;
				div.style.height = h  + &#039;px&#039;;
				//offset the background relative to the position of the div
				div.style.backgroundPosition = (-i * w) +&#039;px &#039;+(-j * h )+&#039;px&#039;;
				var matrix = new WebKitCSSMatrix();
				//if it is the first image
				if(first){
					//no image rotation and full opacity
					div.style.webkitTransform	= matrix.rotate(0, 0, 0);
					div.style.opacity = 1;
				}
				else{
					//random X and Y rotation and a Z translation
					var newX = Math.random() * 360;
					var newY = Math.random() * 360;
					div.style.webkitTransform	= matrix.rotate(newX, newY, 0).translate(0, 0, 380);
				}
				document.body.appendChild(div);

			}
		}

	};
</pre>
<p>The second function was to break up the image by changing the rotation and translation of each div:</p>
<pre class="brush: js">
	shatter.shatter = function(uid){
		var sections = document.getElementsByClassName(uid);
		//loop through each panel of this image
		for(var i = 0, l = sections.length; i &lt; l; i++){
			var theTransform = window.getComputedStyle(sections[i]).webkitTransform;
			var matrix = new WebKitCSSMatrix(theTransform);
			var newX = Math.random() * 360;
			var newY = Math.random() * 360;
			//give each panel a random X and Y rotation and set opacity to 0
			sections[i].style.webkitTransform	= matrix.rotate(newX, newY, 0).translate(0, 0, 380);
			sections[i].style.opacity = 0;
		}
	};
</pre>
<p>And finally a function to reassemble an image:</p>
<pre class="brush: js">
	shatter.unShatter = function(uid){
		var sections = document.getElementsByClassName(uid);
		//loop through each panel of this image
		for(var i = 0, l = sections.length; i &lt; l; i++){
			var matrix = new WebKitCSSMatrix();
			sections[i].style.webkitTransform	= matrix.rotate(0, 0, 0).translate(0, 0, 0);
			sections[i].style.opacity = 1;
		}

	};
</pre>
<p>And of course some css was needed to handle the transitions</p>
<pre class="brush: css">
.imgSection {
	position: absolute;
	-webkit-transition-property: -webkit-transform, left, opacity;
	-webkit-transition-duration: 1000ms, 1000ms, 1000ms;
	-webkit-transition-timing-function : ease-out, ease-out, linear;
	-webkit-transition-delay: 0, 500ms, 0;
	-webkit-backface-visibility: hidden;
	-webkit-transform-style: preserve-3d;
	opacity:0;
}
.img1{
	background: url(../img/cb1.jpg) no-repeat 0 0;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://superted.me/shattering-images/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Touch event tool</title>
		<link>http://superted.me/touch-event-tool</link>
		<comments>http://superted.me/touch-event-tool#comments</comments>
		<pubDate>Tue, 27 Apr 2010 20:56:41 +0000</pubDate>
		<dc:creator>ted</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[events]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[touch]]></category>
		<category><![CDATA[webkit]]></category>
		<category><![CDATA[webOS]]></category>

		<guid isPermaLink="false">http://superted.me/?p=73</guid>
		<description><![CDATA[I just though I&#8217;d share a little tool I built to help me understand touch events on the iPhone. If you are using a touch enabled webkit browser you can see the tool in action using the following link http://bit.ly/touchEvent. I&#8217;ve only tested this on an iPhone but I&#8217;d be interested to hear if it [...]]]></description>
			<content:encoded><![CDATA[<p>I just though I&#8217;d share a little tool I built to help me understand touch events on the iPhone. If you are using a touch enabled webkit browser you can see the tool in action using the following link <a href="http://bit.ly/touchEvent">http://bit.ly/touchEvent</a>. I&#8217;ve only tested this on an iPhone but I&#8217;d be interested to hear if it works on android and webOS phones.</p>
<p>And here&#8217;s the code.</p>
<pre class="brush: js">
var template = &#039;&lt;ul&gt;&#039;+
					&#039;&lt;li&gt;identifier:{identifier}&lt;/li&gt;&#039;+
					&#039;&lt;li&gt;screenX:{screenX}&lt;/li&gt;&#039;+
					&#039;&lt;li&gt;screenY:{screenY}&lt;/li&gt;&#039;+
					&#039;&lt;li&gt;clientX:{clientX}&lt;/li&gt;&#039;+
					&#039;&lt;li&gt;clientY:{clientY}&lt;/li&gt;&#039;+
				&#039;&lt;/ul&gt;&#039;;
var FIRST_FINGER = 0, SECOND_FINGER = 1
document.addEventListener(&#039;touchstart&#039;, function(e) {
	e.preventDefault();
	//identify as the first finger
	jTouchTest.currentFingers[e.touches[0].identifier] = FIRST_FINGER;
	//use supplant function to print out the properties of the e.touches object for the first finger
	document.getElementById(&#039;touchStart&#039;)
			.getElementsByClassName(&#039;touch&#039;)[0]
			.getElementsByTagName(&#039;div&#039;)[0]
			.innerHTML = supplant(template, e.touches[0]);
	//if there is a secondary touch
	if(e.touches[1]){
		//identify as the second finger
		jTouchTest.currentFingers[e.touches[1].identifier] = SECOND_FINGER;
		//use supplant function to print out the properties of the e.touches object for the first second
		document.getElementById(&#039;touchStart&#039;)
				.getElementsByClassName(&#039;touch&#039;)[1]
				.getElementsByTagName(&#039;div&#039;)[0]
				.innerHTML = supplant(template, e.touches[1]);
	}

}, false);
document.addEventListener(&#039;touchmove&#039;, function(e) {
	e.preventDefault();
	//which finger is it
	var finger = jTouchTest.currentFingers[e.changedTouches[0].identifier];
	//use supplant function to print out the properties of the e.changedTouches object for the finger that is moving
	document.getElementById(&#039;touchMove&#039;)
			.getElementsByClassName(&#039;touch&#039;)[finger]
			.getElementsByTagName(&#039;div&#039;)[0]
			.innerHTML = supplant(template, e.changedTouches[0]);
	//if there is a second touch
	if(e.changedTouches[1]){
		finger = jTouchTest.currentFingers[e.changedTouches[1].identifier];
		document.getElementById(&#039;touchMove&#039;)
				.getElementsByClassName(&#039;touch&#039;)[finger]
				.getElementsByTagName(&#039;div&#039;)[0]
				.innerHTML = supplant(template, e.changedTouches[1]);
	}

}, false);
document.addEventListener(&#039;touchend&#039;, function(e) {
	e.preventDefault();
	//if this event matches one the current touches
	if(jTouchTest.currentFingers[e.changedTouches[0].identifier] !== undefined){
		//which finger is it
		var finger = jTouchTest.currentFingers[e.changedTouches[0].identifier];
		//use supplant function to print out the properties of the e.changedTouches object for the finger that has left the screen
		document.getElementById(&#039;touchEnd&#039;)
				.getElementsByClassName(&#039;touch&#039;)[finger]
				.getElementsByTagName(&#039;div&#039;)[0]
				.innerHTML = supplant(template, e.changedTouches[0]);
	}

}, false);
</pre>
]]></content:encoded>
			<wfw:commentRss>http://superted.me/touch-event-tool/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Toy Story iAd Navigation</title>
		<link>http://superted.me/toy-story-iad-navigation</link>
		<comments>http://superted.me/toy-story-iad-navigation#comments</comments>
		<pubDate>Mon, 19 Apr 2010 21:31:18 +0000</pubDate>
		<dc:creator>ted</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[3d]]></category>
		<category><![CDATA[apple]]></category>
		<category><![CDATA[css3]]></category>
		<category><![CDATA[html5]]></category>
		<category><![CDATA[iAd]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[jobs]]></category>

		<guid isPermaLink="false">http://superted.me/?p=21</guid>
		<description><![CDATA[So I&#8217;m sure many of you will have seen Steve Jobs show off the new iAd platform and if you&#8217;re a developer like myself you were probably interested to see that the iAd platform is HTML5 based. As part of the Toy Story 3 iAd there was a nice 3d carousel for the video navigation [...]]]></description>
			<content:encoded><![CDATA[<p>So I&#8217;m sure many of you will have seen Steve Jobs show off the new iAd platform and if you&#8217;re a developer like myself you were probably interested to see that the iAd platform is HTML5 based. As part of the Toy Story 3 iAd there was a nice 3d carousel for the video navigation as shown below.</p>
<p><object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/1LfiJOf7pFg&#038;hl=en_US&#038;fs=1&#038;start=80"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/1LfiJOf7pFg&#038;hl=en_US&#038;fs=1&#038;&#038;start=80" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object></p>
<p>Anyway, Jobsie reckoned that making something like this in HTML5 was &#8216;real easy&#8217; so I thought I&#8217;d see if he was right. If you&#8217;ve got an iphone head over to <a href="Http://bit.ly/iAdEasy" target="_blank">bit.ly/iAdEasy</a> for the full &#8216;emotional&#8217; experience of the results, or you can see a screencast below.</p>
<div style="float:left; width:300px;height:477;margin-right:10px"><object width="300" height="477"><param name="allowfullscreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="movie" value="http://vimeo.com/moogaloop.swf?clip_id=11055757&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=1" /><embed src="http://vimeo.com/moogaloop.swf?clip_id=11055757&amp;server=vimeo.com&amp;show_title=1&amp;show_byline=1&amp;show_portrait=1&amp;color=00adef&amp;fullscreen=1" type="application/x-shockwave-flash" allowfullscreen="true" allowscriptaccess="always" width="300" height="477"></embed></object></div>
<p>I used pictures of my brother&#8217;s dog, Chopper, instead of pixar characters as his images aren&#8217;t copywrited and he doesn&#8217;t have lawyers!</p>
<p style="clear:both">So was it real easy? Well it wasn&#8217;t real easy but that was partly as there isn&#8217;t a huge amount of documentation or tutorials out there.</p>
<p style="font-style:italic">[Update] To clarify this point, all CSS3 transitions/animations are fully documented on the Webkit and Apple websites, it&#8217;s just that it takes a bit of digging to find exactly what you are looking for and there aren&#8217;t many tutorials which show features like WebKitCSSMatrix in action.</p>
<p>I used the webkit team&#8217;s <a href="http://webkit.org/blog-files/3d-transforms/morphing-cubes.html" target="_blank">morphing cube example</a> as my starting point as that showed how to get a bunch of flat elements arranged as a 3d ring. I just created a function to add the 3d transform to each li dynamically rather than in the css file:</p>
<pre class="brush: js">
jAd.createRing = function(){
		var items = shape.getElementsByTagName(&#039;li&#039;);
		var angle = 360 / items.length, newAngle;
		for(var i = 0, l = items.length; i &lt; l; i++){
			newAngle = (angle * i);
			var matrix = new WebKitCSSMatrix();
			items[i].style.webkitTransform	= matrix.rotate(newAngle, 0, 0).translate(0, 0, 380);
		}
	}
</pre>
<p>The next step was to bind the finger swiping events. Webkit allows you to bind &#8216;touchstart&#8217;, &#8216;touchmove&#8217; and &#8216;touchend&#8217; events to any html element and from the touch event you can access the screenPosition and the time of the touch. Using these it is easy to determine which direction the swipe is and how hard the user swiped</p>
<pre class="brush: js">
jAd.bindTouches = function(){
//ignore the touchmove event
		document.addEventListener(&#039;touchmove&#039;, function(e) {e.preventDefault();});
		document.addEventListener(&#039;touchstart&#039;, function(e) {
			e.preventDefault();
//e.touches is an array (for multitouch usage) but we just want the first finger down
			var touch = e.touches[0];
//save the time and the screenY coordinate
			jAd.currentTouch.startY = touch.screenY;
			jAd.currentTouch.startTime = e.timeStamp;
		}, false);
		document.addEventListener(&#039;touchend&#039;, function(e) {
			e.preventDefault();
			var touch = e.changedTouches[0];
			jAd.currentTouch.endY = touch.screenY;
 //work out the speed using the saved coordinate and time
			var time = e.timeStamp - jAd.currentTouch.startTime;
			var speed = (jAd.currentTouch.startY - jAd.currentTouch.endY)/time;
 //send the speed to the spin function
			jAd.spin(speed);

		}, false);
	};
</pre>
<p>The speed that is sent to the spin function can be positive or negative and this determines which way the nav spins.</p>
<p>Next I had to create a function to change the rotation of the &lt;ul&gt; element which contains the &lt;li&gt; elements that make up the ring.</p>
<pre class="brush: js">
jAd.spin = function(speed){
 //get a string representation of the current 3dCSSMatrix of the &lt;ul&gt; (jAd.shape)
		var theTransform = window.getComputedStyle(jAd.shape).webkitTransform;
 //from this create a new WebKitCSSMatrix
		var matrix = new WebKitCSSMatrix(theTransform);
 //do some stuff to get a number that is somewhere between 0 and 179
		var newX = Math.round(speed * 120);
		newX = (newX &gt; 179) ? 179 : ((newX &lt; -179) ? -179 : newX);
//rotate the &lt;ul&gt; in the x plane by this value
		shape.style.webkitTransform	= matrix.rotate(newX, 0, 0);
	};
</pre>
<p>Note that this function doesn&#8217;t animate the ring, it simply changes the rotateX value of the webkit-transform css property. In order to get the animation to happen we have to give the  &lt;ul&gt; some webkit-transition css.</p>
<pre class="brush: css">
#shape {
/* this tell it to animate whenever the -webkit-trasform property changes */
	-webkit-transition-property: -webkit-transform;
	-webkit-transition-duration: 1500ms;
	-webkit-transition-timing-function : ease-out;
	-webkit-transition-delay: 0;
}
</pre>
<p>And that&#8217;s pretty much it, feel free to dig around in the source code and do some experimenting. I haven&#8217;t added any interaction to the contents of the carousel yet, I&#8217;ll be doing that soon and writing another post.</p>
<p>This is my first time I&#8217;ve written a how-to so sorry if I glossed over anything. Feel free to post questions in the comments and I&#8217;ll do my best to answer them</p>
]]></content:encoded>
			<wfw:commentRss>http://superted.me/toy-story-iad-navigation/feed</wfw:commentRss>
		<slash:comments>43</slash:comments>
		</item>
		<item>
		<title>Welcome to superted.me</title>
		<link>http://superted.me/welcome-to-superted-me</link>
		<comments>http://superted.me/welcome-to-superted-me#comments</comments>
		<pubDate>Mon, 19 Apr 2010 21:15:57 +0000</pubDate>
		<dc:creator>ted</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://superted.me/?p=58</guid>
		<description><![CDATA[Hi, thanks for visiting my blog, here’s a bit about me.
My name is Ted. I’m not that super. However I did enjoy watching Superted as a kid and thought it would make a good blog title so there you go.
I’m a web interface developer by trade so that is what I’ll be blogging about mostly. [...]]]></description>
			<content:encoded><![CDATA[<p>Hi, thanks for visiting my blog, here’s a bit about me.</p>
<p>My name is Ted. I’m not that super. However I did enjoy watching <a href="http://www.youtube.com/watch?v=OZg74STOfig" target="_blank">Superted</a> as a kid and thought it would make a good blog title so there you go.</p>
<p>I’m a web interface developer by trade so that is what I’ll be blogging about mostly. I’m really interested in innovative user interfaces and data visualisation using the latest funky HTML5 and CSS3 techniques so I plan to talk about that a fair bit as well as other stuff which catches my eye.</p>
<p>You can find out more about me and my contact details at my portfolio site <a href="http://tedlittledale.co.uk" target="_blank">tedlittledale.co.uk</a>. I also thought I&#8217;d better be a tweeter if I&#8217;m going to try to be a blogger so I&#8217;d love for you to <a href="http://twitter.com/_superted" target="_blank">follow me</a> and boost my numbers (I currently have 3 followers).</p>
]]></content:encoded>
			<wfw:commentRss>http://superted.me/welcome-to-superted-me/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

