<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:posterous="http://posterous.com/help/rss/1.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:media="http://search.yahoo.com/mrss/">
  <channel>
    <title>Zebradog Digital</title>
    <link>http://digital.zebradog.com</link>
    <description>Most recent posts at Zebradog Digital</description>
    <generator>posterous.com</generator>
    <link type="application/json" rel="http://api.friendfeed.com/2008/03#sup" xmlns="http://www.w3.org/2005/Atom" href="http://posterous.com/api/sup_update#a1333052a"/>
    <atom:link rel="self" href="http://digital.zebradog.com/rss.xml"/>
    <atom:link rel="hub" href="http://posterous.superfeedr.com"/>
    <item>
      <pubDate>Fri, 20 May 2011 16:35:00 -0700</pubDate>
      <title>Animated GIF timing with jQuery</title>
      <link>http://digital.zebradog.com/animated-gif-timing-with-jquery-25486</link>
      <guid>http://digital.zebradog.com/animated-gif-timing-with-jquery-25486</guid>
      <description>
        <![CDATA[<p>
	<p>Every now and then I run into a situation where using an animated GIF actually makes sense. In this case, I needed to synchronize the GIF with the end of a RaphaelJS animation (<a href="http://zebradog-digital.tumblr.com/post/7273427930/raphaeljs-svg-import">more&nbsp;details on that here.</a>).&nbsp;</p>
<p>You should be able to create a non-looping .gif and use a standard jQuery image onload technique as follows to ensure the gif had been completely loaded before animating (simply binding the &ldquo;load&rdquo; event to an image will not trigger in all browsers if the image has been cached):</p>
<blockquote>
<p>var logo = &ldquo;images/logo-animated.gif&rdquo;;<br />$(&ldquo;&lt;img /&gt;&rdquo;).one(&lsquo;load&rsquo;,function(){&nbsp;<br /><span> </span>$(this).remove();<br /><span> </span>mySVG.animate(attributes,speed,function(){&nbsp;<br /><span> </span>//animation callback<br /><span> $(&lsquo;img</span>#logo<span>&rsquo;).attr(&lsquo;src&rsquo;,logo);</span><br /><span> </span>}<span> <br /></span>}).attr(&lsquo;src&rsquo;,logo).each(function(){<br /><span> </span>if(this.complete) $(this).trigger(&lsquo;load&rsquo;);<br />});&nbsp;</p>
</blockquote>
<p>This works on all browsers EXCEPT Firefox (or other Mozilla-based). Because Firefox tracks the animation of a .gif based on the asset name (the actual file name) instead of the DOM element, it will only loop once for ALL instances of that image. Because we pre-loaded the image it has already begun and possibly finished looping.. making the animation timing unpredictable.&nbsp;<p />To solve this, I created a version of the .gif with a delay at the beginning with the same length as the animation and load this image only in Mozilla-based browsers:</p>
<blockquote>
<p>var logo = &ldquo;images/logo-animated.gif&rdquo;;<br />var logoDelayed = &ldquo;images/logo-animated-delayed.gif&rdquo;;<br />if($.browser.mozilla) {<br /><span> </span>$(&lsquo;img#logo&rsquo;).attr(&lsquo;src&rsquo;,logoDelayed+&rsquo;?ts=&rsquo;+(new Date()).getTime());<br /><span> $(&lsquo;</span>img<span>#logo&rsquo;).load(function(){<br /></span><span> </span>mySVG.animate(attributes,speed);<span> <br /></span><span> </span>}<br />}else{</p>
<p>&nbsp;</p>
<p><span> </span>$(&ldquo;&lt;img /&gt;&rdquo;).one(&lsquo;load&rsquo;,function(){&nbsp;<br /><span> </span>$(this).remove();<br /><span> </span>mySVG.animate(attributes,speed,function(){<br /><span> </span>//animation callback<br /><span> $(&lsquo;img</span>#logo<span>&rsquo;).attr(&lsquo;src&rsquo;,logo);<br /></span><span> </span>}<span> <br /></span><span> </span>}).attr(&lsquo;src&rsquo;,logo).each(function(){<br /><span> </span>if(this.complete) $(this).trigger(&lsquo;load&rsquo;);<br />});&nbsp;</p>
</blockquote>
<p><strong><a href="http://zebradog.github.com/demo/aacd/" title="Animated GIF timing demo" target="_blank">Final Demo</a></strong></p>
	
</p>

<p><a href="http://digital.zebradog.com/animated-gif-timing-with-jquery-25486">Permalink</a> 

	| <a href="http://digital.zebradog.com/animated-gif-timing-with-jquery-25486#comment">Leave a comment&nbsp;&nbsp;&raquo;</a>

</p>]]>
      </description>
      <posterous:author>
        <posterous:userImage>http://files.posterous.com/user_profile_pics/1330827/699967148_9Hsqo-350x350.jpg</posterous:userImage>
        <posterous:profileUrl>http://posterous.com/people/hckigWXs4PwYq</posterous:profileUrl>
        <posterous:firstName>Matt</posterous:firstName>
        <posterous:lastName>Cook</posterous:lastName>
        <posterous:nickName>Matt Cook</posterous:nickName>
        <posterous:displayName>Matt Cook</posterous:displayName>
      </posterous:author>
    </item>
    <item>
      <pubDate>Sun, 13 Mar 2011 21:00:00 -0700</pubDate>
      <title>Rapha&#235;lJS SVG import</title>
      <link>http://digital.zebradog.com/post/7273427930/raphaeljs-svg-import</link>
      <guid>http://digital.zebradog.com/post/7273427930/raphaeljs-svg-import</guid>
      <description>
        <![CDATA[<p>
	<p><a href="http://raphaeljs.com/">Rapha&euml;l</a> is a fantastic library for manipulating vector images on the web. Sadly, it does not support importing .svg files, allowing you to work with a standard image format.&nbsp;</p>
<p>Wout Fierens has written <a href="https://github.com/wout/raphael-svg-import">a nice plugin</a> to solve this problem and we went ahead and <a href="https://github.com/zebradog/raphael-svg-import">updated it</a>, removing the&nbsp;dependency&nbsp;on prototype.js.&nbsp;<p /><strong><a href="http://zebradog.github.com/demo/aacd">See it in action.&nbsp;</a></strong></p>
	
</p>

<p><a href="http://digital.zebradog.com/post/7273427930/raphaeljs-svg-import">Permalink</a> 

	| <a href="http://digital.zebradog.com/post/7273427930/raphaeljs-svg-import#comment">Leave a comment&nbsp;&nbsp;&raquo;</a>

</p>]]>
      </description>
      <posterous:author>
        <posterous:userImage>http://files.posterous.com/user_profile_pics/1330773/2009008_300.jpg</posterous:userImage>
        <posterous:profileUrl>http://posterous.com/people/hckijAfm81cdY</posterous:profileUrl>
        <posterous:firstName>Mark</posterous:firstName>
        <posterous:lastName>Schmitz</posterous:lastName>
        <posterous:nickName>zebradog</posterous:nickName>
        <posterous:displayName>Mark Schmitz</posterous:displayName>
      </posterous:author>
    </item>
    <item>
      <pubDate>Sun, 13 Mar 2011 15:39:00 -0700</pubDate>
      <title>Rapha&#235;lJS SVG import</title>
      <link>http://digital.zebradog.com/raphaeljs-svg-import-78749</link>
      <guid>http://digital.zebradog.com/raphaeljs-svg-import-78749</guid>
      <description>
        <![CDATA[<p>
	<p><a href="http://raphaeljs.com/">Rapha&euml;l</a> is a fantastic library for manipulating vector images on the web. Sadly, it does not support importing .svg files, allowing you to work with a standard image format.&nbsp;</p>
<p>Wout Fierens has written <a href="https://github.com/wout/raphael-svg-import">a nice plugin</a> to solve this problem and we went ahead and <a href="https://github.com/zebradog/raphael-svg-import">updated it</a>, removing the&nbsp;dependency&nbsp;on prototype.js.&nbsp;<p /><strong><a href="http://zebradog.github.com/demo/aacd">See it in action.&nbsp;</a></strong></p>
	
</p>

<p><a href="http://digital.zebradog.com/raphaeljs-svg-import-78749">Permalink</a> 

	| <a href="http://digital.zebradog.com/raphaeljs-svg-import-78749#comment">Leave a comment&nbsp;&nbsp;&raquo;</a>

</p>]]>
      </description>
      <posterous:author>
        <posterous:userImage>http://files.posterous.com/user_profile_pics/1330827/699967148_9Hsqo-350x350.jpg</posterous:userImage>
        <posterous:profileUrl>http://posterous.com/people/hckigWXs4PwYq</posterous:profileUrl>
        <posterous:firstName>Matt</posterous:firstName>
        <posterous:lastName>Cook</posterous:lastName>
        <posterous:nickName>Matt Cook</posterous:nickName>
        <posterous:displayName>Matt Cook</posterous:displayName>
      </posterous:author>
    </item>
  </channel>
</rss>
