<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" 
      xmlns:thr="http://purl.org/syndication/thread/1.0">
  <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html" />
  <link rel="self" type="application/atom+xml" href="http://www.insideria.com/atom.xml" />
  <id>tag:www.insideria.com,2009://34/tag:www.insideria.com,2008://34.34512-</id>
  <updated>2009-11-16T15:23:21Z</updated>
  <title>Comments for Building a Simple Progress Bar Using the Scriptaculous Morph Function (http://www.insideria.com/2008/12/building-a-simple-progress-bar.html)</title>
  <generator uri="http://www.sixapart.com/movabletype/">Movable Type 4.21-en</generator>
  <entry>
    <id>tag:www.insideria.com,2008://34.34512</id>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html" />
    <link rel="service.edit" type="application/atom+xml" href="http://blogs.oreilly.com/cgi-bin/mt/mt-atom.cgi/weblog/blog_id=34/entry_id=34512" title="Building a Simple Progress Bar Using the Scriptaculous Morph Function" />
    <published>2008-12-04T14:00:00Z</published>
    <updated>2008-12-03T19:41:51Z</updated>
    <title>Building a Simple Progress Bar Using the Scriptaculous Morph Function</title>
    <summary>One of the most useful script.aculo.us functions has to be the morph function.  You can use it to modify a CSS style over a set period of time, making it the perfect function for creating an animated progress bar for a JavaScript based RIA.</summary>
    <author>
      <name>Jeremy Bierly</name>
      
    </author>
    
    <category term="Blogs" />
    
    <content type="html" xml:lang="en" xml:base="http://www.insideria.com/">
      <![CDATA[<p>One of the most useful <a href="http://script.aculo.us">script.aculo.us</a> functions has to be the morph function.  You can use it to modify a CSS style over a set period of time, making it the perfect function for creating an animated progress bar for a JavaScript based RIA.</p>

<p>Below is a quick example showing how to use the morph function.</p>

<p>In this example I begin by creating a couple of quick graphics. The first is for the progress bar and a the second is transparent gif to act as a border and a masking agent for the progress bar.  The gif image is not necessary, but it does give us a quick and easy way to create rounded corners for the progress bar.</p>

<p>After the graphics are saved, I create a simple html page with a div for the progress bar.  I'll add some CSS to style the progress bar div as follows:</p>

<pre>
.progressBar
{
    width: 480px;
    height: 30px;
    background: url(progressBar.png) left no-repeat;
    padding: 0;
    margin: 0;
}
</pre>

<p>I then add a javascript reference to prototype.js and effects.js from scriptaculous.</p>

<p>Next, I add a dom:loaded event handler to initialize my progressbar. I also use the event to add the progress bar mask image.  Then I set the background position to -480px (the length of the div).  Finally I use the morph function to change the background position to 0px over a duration of 4 seconds.</p>

<p>below is the code:<br />
<pre><br />
document.observe("dom:loaded",function() {<br />
    var pb = $('sampleProgressBar');<br />
    pb.insert("&lt;img src=\"progressBarMask.gif\" alt=\"progress bar\" /&gt;");<br />
    pb.setStyle({backgroundPosition: '-480px'});<br />
    pb.morph({backgroundPosition: '0px'}, { duration: 4 });<br />
});<br />
</pre></p>]]>
      
    </content>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.34512-comment:2048142</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.34512" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html#comment-2048142" />
    <title>Comment from John Rudy on 2008-12-04</title>
    <author>
        <name>John Rudy</name>
        <uri>http://www.codeheaven.info</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://www.codeheaven.info">
        <![CDATA[<p>Awesome technique ... Looking forward to reading more of these as I try to get into the RIA world from my too-traditional browser and desktop GUI world.</p>]]>
    </content>
    <published>2008-12-04T17:34:35Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.34512-comment:2048157</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.34512" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html#comment-2048157" />
    <title>Comment from Lawrence on 2008-12-04</title>
    <author>
        <name>Lawrence</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Well done Mr. Bierly. </p>

<p>Using an image mask and background image moved via JS can provide a variety of effects.</p>

<p>You didn't mention why the background image is positioned out of sight using JS and not CSS.<br />
</p>]]>
    </content>
    <published>2008-12-04T20:39:12Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.34512-comment:2055733</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.34512" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html#comment-2055733" />
    <title>Comment from Dave on 2009-03-22</title>
    <author>
        <name>Dave</name>
        <uri></uri>
    </author>
    <content type="html" xml:lang="en" xml:base="">
        <![CDATA[<p>Do you have a sample code combine in zip file? So that we can download it. It doesnt work for me.. Thank you...</p>]]>
    </content>
    <published>2009-03-22T20:37:32Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.34512-comment:2060321</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.34512" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html#comment-2060321" />
    <title>Comment from nils on 2009-05-25</title>
    <author>
        <name>nils</name>
        <uri>http://snackycracky.wordpress.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://snackycracky.wordpress.com">
        <![CDATA[<p>.progressBar<br />
{<br />
    border:1px solid grey;<br />
    width: 480px;<br />
    height: 30px;<br />
    padding: 0;<br />
    margin: 0;<br />
}</p>





<p><br />
javascript:</p>

<p>document.observe("dom:loaded",function() {</p>

<p>    var pb = $('sampleProgressBar');</p>

<p>    pb.setStyle({background: 'progressBar.gif'});<br />
    pb.setStyle({backgroundPosition: '-480px'});</p>

<p>    pb.morph({backgroundPosition: '0px'}, { duration: 4 });</p>

<p>});</p>]]>
    </content>
    <published>2009-05-25T14:07:07Z</published>
  </entry>

  <entry>
    <id>tag:www.insideria.com,2008://34.34512-comment:2060322</id>
    <thr:in-reply-to ref="tag:www.insideria.com,2008://34.34512" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html"/>
    <link rel="alternate" type="text/html" href="http://www.insideria.com/2008/12/building-a-simple-progress-bar.html#comment-2060322" />
    <title>Comment from nils on 2009-05-25</title>
    <author>
        <name>nils</name>
        <uri>http://snackycracky.wordpress.com</uri>
    </author>
    <content type="html" xml:lang="en" xml:base="http://snackycracky.wordpress.com">
        <![CDATA[<p>&lt;div id=&quot;sampleProgressBar&quot; class=&quot;progressBar&quot;&gt;</p>
<p>&lt;/div&gt;</p>]]>
    </content>
    <published>2009-05-25T14:11:12Z</published>
  </entry>

</feed
