<?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:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Snook.ca</title><link>http://snook.ca/</link><description>Tips, Tricks and Bookmarks on Web Development.</description><language>en</language><geo:lat>45.1800</geo:lat><geo:long>-75.5500</geo:long><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" href="http://feeds.feedburner.com/snookca" type="application/rss+xml" /><feedburner:browserFriendly>This is an XML content feed. It is intended to be viewed in a newsreader or syndicated to another site, subject to copyright and fair use.</feedburner:browserFriendly><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com" /><item><title>HTML in a Flash World</title><link>http://feedproxy.google.com/~r/snookca/~3/FQn9awcCLSw/html-flash-air</link><author>jonathan@snook.ca (Jonathan Snook)</author><pubDate>Wed, 08 Jul 2009 10:40:44 PDT</pubDate><guid isPermaLink="false">http://snook.ca/archives/adobe_air/html-flash-air</guid><description>&lt;p&gt;Last night, I had the pleasure of presenting a short little session on HTML development within Adobe AIR and what the perks and pitfalls were. The feedback I got afterwards was very positive and I hope everybody there got something out of it.&lt;/p&gt;
&lt;p&gt;As promised, I'm providing the slides in both &lt;a href="http://snook.ca/files/html-in-a-flash-world.pdf"&gt;PDF&lt;/a&gt; or &lt;a href="http://snook.ca/files/html-in-a-flash-world.key"&gt;Keynote&lt;/a&gt;. &lt;/p&gt;
&lt;p&gt;Here are the resources that I talked about and have linked to in the slides:&lt;/p&gt;
&lt;ul&gt;
  &lt;li&gt;&lt;a href="http://www.adobe.com/products/air/tools/sdk/"&gt;Adobe AIR SDK&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href="http://www.adobe.com/devnet/air/ajax/"&gt;Adobe AIR
    Developer Center&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;    &lt;a href="http://extjs.com/"&gt;Ext JS&lt;/a&gt; has AIR interface&lt;/li&gt;
  &lt;li&gt; &lt;a href="http://www.adobe.com/devnet/air/ajax/articles/blackbooksafe_anatomy.html"&gt;BlackBookSafe&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;Also mentioned in the questions afterwards: &lt;a href="http://www.adobe.com/devnet/air/articles/badger_for_air_apps.html?devcon=f3"&gt;Badger&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/snookca?a=FQn9awcCLSw:0YTSJIQ__Ms:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=FQn9awcCLSw:0YTSJIQ__Ms:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=FQn9awcCLSw:0YTSJIQ__Ms:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=FQn9awcCLSw:0YTSJIQ__Ms:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=FQn9awcCLSw:0YTSJIQ__Ms:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/snookca/~4/FQn9awcCLSw" height="1" width="1"/&gt;</description><feedburner:origLink>http://snook.ca/archives/adobe_air/html-flash-air</feedburner:origLink></item><item><title>Adobe and HTML5's Canvas</title><link>http://feedproxy.google.com/~r/snookca/~3/iB_4buzW5UQ/adobe-html5-canvas</link><author>jonathan@snook.ca (Jonathan Snook)</author><pubDate>Tue, 07 Jul 2009 09:49:27 PDT</pubDate><guid isPermaLink="false">http://snook.ca/archives/opinion/adobe-html5-canvas</guid><description>&lt;p&gt;I had an epiphany and I hope somebody at Adobe has been paying attention to the HTML5 developments. Adobe is well positioned to take advantage of emerging browser features, most specifically canvas. &lt;/p&gt;
&lt;p&gt;As great as canvas is, having a visual tool to assist in taking advantage of that would be ideal. Such a tool would smooth out the rough spots of cross-browser issues and could provide a set of pre-designed widgets and interactions that could be quickly dropped into any project. &lt;/p&gt;
&lt;p&gt;Flash developers would likely find it an easy transition to building canvas-based tools. It'd be easier because of their knowledge of animation and because of the similarities between ActionScript and JavaScript. &lt;/p&gt;
&lt;p&gt;Adobe is also well positioned to integrate a solution across existing applications such as allowing &amp;quot;Export as Canvas&amp;quot; from Flash, or the ability to build a canvas editor for Dreamweaver.&lt;/p&gt;
&lt;p&gt;This isn't a Canvas vs. Flash issue. There are still advantages to both. Building a tool such as this doesn't sabotage their Flash marketshare any more than Dreamweaver does. In fact, having a tool such as this would further entrench Adobe as the de facto provider for web design tools.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/snookca?a=iB_4buzW5UQ:Lb2RjKWdaXE:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=iB_4buzW5UQ:Lb2RjKWdaXE:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=iB_4buzW5UQ:Lb2RjKWdaXE:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=iB_4buzW5UQ:Lb2RjKWdaXE:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=iB_4buzW5UQ:Lb2RjKWdaXE:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/snookca/~4/iB_4buzW5UQ" height="1" width="1"/&gt;</description><feedburner:origLink>http://snook.ca/archives/opinion/adobe-html5-canvas</feedburner:origLink></item><item><title>Behind the Process: Snitter Icon</title><link>http://feedproxy.google.com/~r/snookca/~3/bttI5GCt7XM/snitter-icon-design</link><author>jonathan@snook.ca (Jonathan Snook)</author><pubDate>Fri, 22 May 2009 10:39:51 PDT</pubDate><guid isPermaLink="false">http://snook.ca/archives/design/snitter-icon-design</guid><description>&lt;p&gt;I built this desktop application a while back called &lt;a href="http://getsnitter.com/"&gt;Snitter&lt;/a&gt;. It's a desktop Twitter client that runs on Adobe AIR. Alas, it fell by the wayside during my freelance tenure. Recently, I've had the inclination to start working on it again and bringing forth to reality ideas that I've had for over a year now.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://snook.ca/img/snitter/snitter-48.png" alt="The original S icon" align="right" /&gt;One of the things that always bothered me was the rather rushed icon. A rather boring S. I was just happy that I had a desktop app with its own icon. I knew I'd get around to getting a new, more polished icon at some point.&lt;/p&gt;
&lt;h2&gt;Who can? A Toucan.&lt;/h2&gt;
&lt;p&gt;Being a Twitter app, I wanted to stick with the bird motif but also wanted a bird that had some colour to it &amp;mdash; especially green. The toucan came to mind, as images of Toucan Sam and his colourful beak filled my head. &lt;/p&gt;
&lt;p&gt;In doing research on toucans, I came across a page on &lt;a href="http://healing.about.com/od/animaltotems/ig/Animal-Totems-Photo-Gallery/Toucan.htm"&gt;Toucan totems&lt;/a&gt;. &lt;/p&gt;
&lt;blockquote&gt;
  &lt;p&gt;The toucan represents communication and showmanship. The toucan's colorful appearance and large bill indicates a strong desire to be seen and heard.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If anything sounded more appropriate for a Twitter app, I haven't heard it. The toucan was now the bird.&lt;/p&gt;
&lt;h2&gt;Initial Sketches&lt;/h2&gt;
&lt;p&gt;I'm not an icon designer, so I enlisted the help of Mike Rohde. The fact that he said yes to a free project was music to my ears. I gave him some simple direction that I wanted the icon to be a toucan and he came back with some initial sketches.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.flickr.com/photos/rohdesign/3553822077/"&gt;&lt;img src="http://snook.ca/img/snitter/snitter-sketches-v1.jpg" alt="A couple initial toucan sketches from Mike Rohde" /&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://www.flickr.com/photos/rohdesign/3553822077/"&gt;Check out all the sketches.&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I was definitely starting to get excited. I had started to provide Mike with some further direction, indicating that I really liked the bird looking over the shoulder. I felt it provided more balance and would be easier to work into an icon.&lt;/p&gt;
&lt;p&gt;Alas, a year had gone by and my ability to work on Snitter had disappeared. Sadly, so had Mike's free time. Mike had to bow out. Having been in his shoes, I completely understood. &lt;/p&gt;
&lt;h2&gt;Inspiration&lt;/h2&gt;
&lt;p&gt;Now on my own, I thought I'd give icon design a try. &lt;/p&gt;
&lt;p&gt;One thing I did differently than any other design project I've done before was to create an inspiration document where I threw in a bunch of photos and icons that I liked.&lt;/p&gt;
&lt;p&gt;&lt;img src="http://snook.ca/img/snitter/snitter-inspiration.jpg" alt="Photos of various breeds of toucans and some application icons"&gt;&lt;/p&gt;
 &lt;p&gt;When you see the final icon, I'm sure you'll see where much of the inspiration has come. I started by actually tracing out the shape of one of the birds that was looking over his shoulder. Using the pen tool in Fireworks, I traced out the beak, the head, the chest and the body. The shapes had flat colours and I really just wanted to get the basics of the shape in place.&lt;/p&gt;
 &lt;h3&gt;Circle-bound&lt;/h3&gt;
 &lt;p&gt;Two things that I was missing were a tail and feet. As I started to put the tail in, I begun to see the circle shape come into play. I drew a circle and placed it behind my vectors and tried to lock everything into that shape. I was drawn to using the circle based on the Twtterrific and Firefox logos. (I was tempted to have my bird circle a globe but thought against it.) This is definitely where the most progress was made.&lt;/p&gt;
 &lt;p&gt;&lt;a href="http://www.flickr.com/photos/jonathansnook/3552250640/" title="Snitter Icon by Jonathan Snook, on Flickr"&gt;&lt;img src="http://farm4.static.flickr.com/3664/3552250640_b49f4d3dbf_o.png" alt="Snitter Icon" width="128" height="128" align="right" /&gt;&lt;/a&gt;I had a tail in place and then started on shading. I layered vectors over top of what was there, playing with gradients and colours to create the effect that I wanted. It was after this point where I really started liking how things were coming together. &lt;/p&gt;
 &lt;p&gt;When I posted this version to Flickr, a few people mentioned its similarity to the &lt;a href="http://aviary.com/tools/toucan"&gt;Aviary Toucan&lt;/a&gt;. They did a fantastic job with that toucan. One thing that was extremely evident was how tightly they stuck to a circle for the beak, head and into the body and then breaking out of that with the wings.&lt;/p&gt;
 &lt;p&gt;I took that inspiration and went back to tweaking my toucan. I still didn't want to stick &lt;em&gt;too&lt;/em&gt; close to the circle but I did lengthen the beak, having it follow the edge of the circle, instead of having a more defined hook nose. Where the beak meets the head, I decided to leave it as-is. I didn't want to stylize the bird too much.&lt;/p&gt;
 &lt;h3&gt;Stay on the ground or fly?&lt;/h3&gt;
 &lt;p&gt;I still had no feet and I wasn't really loving the wings. Trying to play with the circle, I tried to get the wings to complete the left side of the circle but everything I tried felt unbalanced, leaving a large space right in the middle of the logo. &lt;/p&gt;
 &lt;p&gt;Starting to grow weary of using the pen tool to shape things, I switched to use circles to punch shapes into crescents for the wings. It was at this point that I used a circle to punch the shape of the toucan's back. I liked it. &lt;/p&gt;
 &lt;p&gt;When I rotated the crescents I had, I tried shifting them into the middle of the space between the head and the body. The crescents were so large that they inadvertently popped out on the other side of the bird. Wait, it looks like wings on the other side! This happy accident got me exactly what I wanted. &lt;/p&gt;
 &lt;p&gt;With the bird in flight, I no longer had to worry about the feet. I tried a couple different things earlier to get feet but they all looked hideous. Feet are not my fort&amp;eacute;, it seems. No worries, as I was really happy with how things were shaping up. (a little vector humour there...)&lt;/p&gt;
 &lt;p&gt;I continued to adjust the shadows, adding highlights to the bottom and the wings to give the bird a little more depth. Finally, I was happy with the result. Like, really happy.&lt;/p&gt;
 &lt;h2&gt;Let it fly!&lt;/h2&gt;
 &lt;p&gt;This will be the icon for the next version of Snitter, which I'm hoping to have out in a couple weeks.&lt;/p&gt;
 &lt;p&gt;&lt;img src="http://snook.ca/img/snitter/snitter-logo.jpg" alt="Photos of various breeds of toucans and some application icons" /&gt;&lt;/p&gt;
 &lt;p&gt;As an added bonus, I'm linking up &lt;a href="http://snook.ca/img/snitter/snitter-icon.png"&gt;the final Fireworks PNG&lt;/a&gt;. Download it and check out how it's all put together. The design is copyright so don't go throwing toucans over everything but pick it apart and use it to inspire your next design. The Fireworks file was created in CS4 and uses the Pages feature where I have an earlier version on page 1 and then the final version on page 2 (a cheap way to do versioning). &lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/snookca?a=bttI5GCt7XM:XEY2MDaKSxs:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=bttI5GCt7XM:XEY2MDaKSxs:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=bttI5GCt7XM:XEY2MDaKSxs:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=bttI5GCt7XM:XEY2MDaKSxs:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=bttI5GCt7XM:XEY2MDaKSxs:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/snookca/~4/bttI5GCt7XM" height="1" width="1"/&gt;</description><feedburner:origLink>http://snook.ca/archives/design/snitter-icon-design</feedburner:origLink></item><item><title>The Elephant in the Room</title><link>http://feedproxy.google.com/~r/snookca/~3/fVY1jcTUURA/elephant-in-the-room</link><author>jonathan@snook.ca (Jonathan Snook)</author><pubDate>Thu, 21 May 2009 07:49:07 PDT</pubDate><guid isPermaLink="false">http://snook.ca/archives/browsers/elephant-in-the-room</guid><description>&lt;p&gt;Almost a month ago, I wrote about &lt;a href="http://snook.ca/archives/opinion/supporting-old-browsers"&gt;supporting older browsers&lt;/a&gt; &amp;mdash; how and whether we should even support them. &lt;/p&gt;
 &lt;blockquote&gt;
   &lt;p&gt;We draw a line in the sand that says, &amp;quot;You popular browsers, stand over here. Everybody else, just be happy you got content.&amp;quot;&lt;/p&gt;
   &lt;p&gt;More specifically, a base style sheet would declare some default font styles but no float or other layout tricks. Just linear content. This default would look decent in any browser, no matter from what era. It makes a great print style sheet, too.&lt;/p&gt;
 &lt;/blockquote&gt;
 &lt;p&gt;The general consensus that came from that was to ignore old browsers like they don't exist. Testing in every browser is impossible. Therefore, we test for what we know and hope for the best with the rest.&lt;/p&gt;
 &lt;p&gt;Today, Andy Clarke (and all that malarkey) released a &lt;a href="http://forabeautifulweb.com/blog/about/universal_internet_explorer_6_css/"&gt;Universal Internet Explorer 6 CSS&lt;/a&gt;. The idea behind it is to provide a simple style sheet devoid of any layout tricks but that still provides a designed experience. Just linear content. This default would look decent in any browser. It even makes a great print style sheet, too.&lt;/p&gt;
 &lt;p&gt;I, personally, prefer this approach of providing a minimalist experience over the idea of preventing people from accessing it altogether. Or berating them for their choice of browser,  assuming they have any choice at all.  We should stop making fun of the kid who dresses funny because his parents can't afford nice clothes.&lt;/p&gt;
 &lt;p&gt;This still doesn't solve the problem for those browsers we no longer want to test in. What of those 83 people that visited my site in the last month with Safari 2? Or the &lt;em&gt;2500&lt;/em&gt; people that were still using Firefox 2? I can only assume that what I've designed looks half decent. I mean, Firefox 2 has decent CSS support, right?&lt;/p&gt;
 &lt;p&gt;I guess we just hope for the best.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/snookca?a=fVY1jcTUURA:Z4UR3foPa7Y:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=fVY1jcTUURA:Z4UR3foPa7Y:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=fVY1jcTUURA:Z4UR3foPa7Y:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=fVY1jcTUURA:Z4UR3foPa7Y:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=fVY1jcTUURA:Z4UR3foPa7Y:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/snookca/~4/fVY1jcTUURA" height="1" width="1"/&gt;</description><feedburner:origLink>http://snook.ca/archives/browsers/elephant-in-the-room</feedburner:origLink></item><item><title>Fixed Position and Opacity Filter Bug in Internet Explorer</title><link>http://feedproxy.google.com/~r/snookca/~3/93m0bLY5_es/ie-position-fixed-opacity-filter</link><author>jonathan@snook.ca (Jonathan Snook)</author><pubDate>Thu, 07 May 2009 11:11:34 PDT</pubDate><guid isPermaLink="false">http://snook.ca/archives/html_and_css/ie-position-fixed-opacity-filter</guid><description>&lt;p&gt;I think I have a knack for discovering weird edge cases but here was a wacky one that had me scratching my head for awhile. In working on some interface development, I wanted to have an element with fixed positioning, locking it to the viewport. In this particular case, it quickly animates in by adjusting the opacity of the element from 0 to 100. Straightforward enough, right?&lt;/p&gt;
 &lt;p&gt;But in Internet Explorer 7 and 8 (even in standards mode), I wasn't able to scroll and while I could type in my form inputs, nothing was showing up. Resizing the browser forced a redraw and everything &lt;em&gt;looked&lt;/em&gt; okay but you still couldn't scroll or see anything  you typed into a text field.&lt;/p&gt;
 &lt;p&gt;Here is the CSS that was causing all the ruckus:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.fixed { 
   position:fixed; 
   filter: alpha(opacity=100); 
   top:15px; right:15px; bottom:15px; 
   width:150px; 
   overflow:auto; 
}&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;I've put together &lt;a href="http://snook.ca/technical/ie-fixed-hidden.html"&gt;a simplified test case&lt;/a&gt; that  demonstrates this. Check it out in IE7 or 8 and you should see the unfortunate side-effect. Click on the Remove Filter button and the functionality of the fixed area should return to normal.&lt;/p&gt;
&lt;p&gt;Putting the test case together for this was a hassle. Because the filter was being applied via script, all my original assumptions weren't working. It was only when I started pasting in rendered HTML from IE (using IE's developer toolbar in IE8) that I was able to recreate the issue (since the rendered HTML had the filter applied).&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/snookca?a=93m0bLY5_es:d70cq4A8tR4:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=93m0bLY5_es:d70cq4A8tR4:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=93m0bLY5_es:d70cq4A8tR4:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=93m0bLY5_es:d70cq4A8tR4:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=93m0bLY5_es:d70cq4A8tR4:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/snookca/~4/93m0bLY5_es" height="1" width="1"/&gt;</description><feedburner:origLink>http://snook.ca/archives/html_and_css/ie-position-fixed-opacity-filter</feedburner:origLink></item><item><title>Shifting my Opinion on CSS Animations</title><link>http://feedproxy.google.com/~r/snookca/~3/AzXLc7egx8o/shifting-opinion-css-animations</link><author>jonathan@snook.ca (Jonathan Snook)</author><pubDate>Tue, 05 May 2009 21:36:08 PDT</pubDate><guid isPermaLink="false">http://snook.ca/archives/html_and_css/shifting-opinion-css-animations</guid><description>&lt;p&gt;When CSS animations were &lt;a href="http://webkit.org/blog/138/css-animation/"&gt;first introduced in Webkit&lt;/a&gt; back in 2007, I expressed my concerns that &lt;a href="http://snook.ca/archives/javascript/css_animations_in_safari/"&gt;CSS may not be the best place for it&lt;/a&gt;.&lt;/p&gt;
 &lt;blockquote&gt;
   &lt;p&gt;Sound cool? I don't think so. Not only does it make CSS more complicated, it makes JavaScript more complicated, too.&lt;/p&gt;
 &lt;/blockquote&gt;
 &lt;p&gt;Having actually taken some time to &lt;a href="http://snook.ca/archives/other/screencast-webkit-in-titanium"&gt;implement CSS animations in an example&lt;/a&gt;, a light bulb clicked. The way I looked at how animations were declared and in what situations you would declare them suddenly changed. I believe I have done a 180 on this. Why and how, you might ask?&lt;/p&gt;
 &lt;h2&gt;Understanding Transitions&lt;/h2&gt;
 &lt;p&gt;The first hurdle for me was understanding how animations were declared. Where do you define them? How do you set the type of animation, the duration, and what should happen? What finally clicked is not that I'm defining an animation.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I'm defining that when an element (based on the CSS selector) has a style property change, that the change happens gradually instead of instantly. &lt;/strong&gt;&lt;/p&gt;
 &lt;p&gt;When I looked at it in this way, it was no longer about JavaScript or behaviour, or anything else but simply defining that property changes shouldn't be instant.&lt;/p&gt;
 &lt;p&gt;Here's a quick example:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;a { color: #039; }
a:hover { color:#333; }&lt;/code&gt;&lt;/pre&gt;
 &lt;p&gt;I'm sure you've seen code like this a zillion times. But what if you wanted the property change to be gradual? &lt;/p&gt;
&lt;pre&gt;&lt;code&gt;a { color: #039; -webkit-transition-duration:.4s; }
a:hover { color:#093; }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Try this in Safari 4 and you'll notice some really nice soft fading between the two states. Imagine declaring this in JavaScript? How cumbersome.&lt;/p&gt;
&lt;h2&gt;Separation of Presentation &lt;/h2&gt;
&lt;p&gt;Which made me make the connection to the  separation of content, behaviour and presentation. &lt;/p&gt;
&lt;p&gt;One thing I've advocated for awhile is representing state changes within JavaScript by changing an element's &lt;code&gt;className&lt;/code&gt; instead of changing numerous style properties. For example, let's say you have a bunch of tabs and you want to indicate that a particular tab is the active tab. The easiest way to do that is to attach a click event handler to a tab and then apply an active class to it (while at the same time removing the active class from any element that may already be active).&lt;/p&gt;
&lt;p&gt;If the active tab was to be 10 pixels higher, then it'd be easy enough to declare this via CSS:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;.tab { position:relative; top:10px; -webkit-transition: top .4s; }
.tab.active { top:0; }&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When the active class is applied to the tab, its position is automatically transitioned from 10px to 0. In this case, I also explicitly indicated that the transition should only apply to the top property. &lt;/p&gt;
&lt;h2&gt;Detecting when an animation is complete&lt;/h2&gt;
&lt;p&gt;One of the other hesitations I had with CSS animations was the uncertainty of how animations would conflict with other  JavaScript code that may be running at the same time. As I understand it, inspection midway will report accurate computed styles at the point of animation.&lt;/p&gt;
&lt;p&gt;To detect whether an animation has completed, you need to be on the lookout for the transitionEnd event which fires on the element that was transitioned. For now, the event needs to be prefixed with &lt;code&gt;webkit&lt;/code&gt;, which is a little unusual in the world of JavaScript.&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;myElement.addEventListener('webkitTransitionEnd', myFunction);&lt;/code&gt;&lt;/pre&gt;
&lt;h2&gt;Progressive Enhancement&lt;/h2&gt;
&lt;p&gt;Finally, one of the things that I like about this is its ability to be applied quickly while still allowing the same interaction in all other browsers, albeit minus the animation &amp;mdash; an animation that is purely presentational in this case. &lt;/p&gt;
&lt;p&gt;I don't believe this is the solution for all browser animations. Far from it. While more complex animations can still be handled via JavaScript, I like the declarative way of describing that an element's properties are transitionable.&lt;/p&gt;
&lt;p&gt;I've seen plenty of people jump on the text-shadow, box-shadow, or rgba bandwagon. I now see transitions as being yet another tool to soften the experience for a segment of your visitors. &lt;/p&gt;
&lt;p&gt;While I was reluctant to see this gain traction, I'm much more receptive to it now and would like to see other browsers get this implemented.&lt;/p&gt;&lt;div class="feedflare"&gt;
&lt;a href="http://feeds.feedburner.com/~ff/snookca?a=AzXLc7egx8o:n5raCNqavRU:yIl2AUoC8zA"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?d=yIl2AUoC8zA" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=AzXLc7egx8o:n5raCNqavRU:F7zBnMyn0Lo"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=AzXLc7egx8o:n5raCNqavRU:F7zBnMyn0Lo" border="0"&gt;&lt;/img&gt;&lt;/a&gt; &lt;a href="http://feeds.feedburner.com/~ff/snookca?a=AzXLc7egx8o:n5raCNqavRU:gIN9vFwOqvQ"&gt;&lt;img src="http://feeds.feedburner.com/~ff/snookca?i=AzXLc7egx8o:n5raCNqavRU:gIN9vFwOqvQ" border="0"&gt;&lt;/img&gt;&lt;/a&gt;
&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/snookca/~4/AzXLc7egx8o" height="1" width="1"/&gt;</description><feedburner:origLink>http://snook.ca/archives/html_and_css/shifting-opinion-css-animations</feedburner:origLink></item></channel></rss>
