<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Cs164projects39&#039;s Blog</title>
	<atom:link href="http://cs164projects39.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://cs164projects39.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Sat, 19 Dec 2009 07:54:31 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='cs164projects39.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Cs164projects39&#039;s Blog</title>
		<link>http://cs164projects39.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://cs164projects39.wordpress.com/osd.xml" title="Cs164projects39&#039;s Blog" />
	<atom:link rel='hub' href='http://cs164projects39.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Write-up Parts 3 and 4</title>
		<link>http://cs164projects39.wordpress.com/2009/12/19/write-up-parts-3-and-4/</link>
		<comments>http://cs164projects39.wordpress.com/2009/12/19/write-up-parts-3-and-4/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 07:54:31 +0000</pubDate>
		<dc:creator>cs164projects39</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cs164projects39.wordpress.com/?p=39</guid>
		<description><![CDATA[Part 3: The features of ‘$tween’ Our language will allow the creation of complex dom animation in an intuitive way. We are assuming that the user knows html and CSS, and basic dom selectors, but not javascript or jquery. It should be relatively easy to create interesting visual effects in an intuitive way. Designing for [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cs164projects39.wordpress.com&amp;blog=10602032&amp;post=39&amp;subd=cs164projects39&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Part 3: The features of ‘$tween’</p>
<p>Our language will allow the creation of complex dom animation in an intuitive way.  We are assuming that the user knows html and CSS, and basic dom selectors, but not javascript or jquery.  It should be relatively easy to create interesting visual effects in an intuitive way.   Designing for designers shapes the syntax of our language:</p>
<p>   1. If function arguments have a unit, it should be obvious<br />
   2. There should be no functions where complex parameter arguments need to be remembered<br />
   3. When chaining together an animation, a designer should not have to remember specific order that they need to be chained together with<br />
   4. The design should leverage their current knowledge of the DOM, HTML and CSS<br />
   5. An animation should be built in the most intuitive way possible</p>
<p>Creating a basic animation:<br />
An animation must consist of three basic things: 1) A attribute and how it should be modified, 2) A duration 3) A specific element to move</p>
<p>Because the designers know CSS, they should know the attribute they want to animate and how they want it modifed for example.  There will be an advanced option to pass in a function that modifies a generic div.  This creates a tween instance hereafter notifed as [tween]<br />
$tween({&#8220;width&#8221;: &#8220;50px&#8221;}); // this will animate the object to eventually be 50px wide<br />
$tween({&#8220;width&#8221;: &#8220;+50px&#8221;}); // this will animate the object to eventually be 50px larger than it was initially<br />
$tween({&#8220;width&#8221;: &#8220;x2&#8243;}); // this will animate the object to eventually double it&#8217;s width<br />
$tween(function(i /*between 0 and 1, essentially percentage done */){return {&#8220;width&#8221;: &#8220;&#8221; + i*50 + &#8220;px&#8221;}); // this will animate the object to eventually be 50px wide</p>
<p>A duration can be specified with<br />
[tween].forSeconds(3) // this animation will take 3 seconds<br />
[tween].forMilliseconds(3000) // this animation will take 3000 milliseconds</p>
<p>A tween can be attached to a specific element with<br />
[tween].attach(&#8220;#a&#8221;) // attaches this element to the item #a</p>
<p>Finally a tween can be started with<br />
[tween].go() // starts animation<br />
[tween].go(&#8220;#a&#8221;) // attaches animation to #a and starts animations</p>
<p>Further, tweens can be modified in various ways</p>
<p>A tween can be repeated with<br />
[tween].repeat(3) // animation will repeat 3 times</p>
<p>A tween can be eased with<br />
[tween].ease(&#8216;accelerate&#8217;) // start moving slowly and accelerate<br />
[tween].ease(&#8216;decelerate&#8217;) // start moving fast and slow down</p>
<p>Two or more tweens can occur simultaneously, in parallel with<br />
$tween.parallel(tween1, tween2,  . . . .) // all tweens start at same time</p>
<p>Two or more tween can occur consecutively, serialized with<br />
$tween.serial(tween1, tween2, tween3) // all tweens happen consecutively</p>
<p>A pause can be created with<br />
$tween.pauseForSeconds(2); // does nothing for two seconds<br />
$tween.pauseForMilliseconds(2000); // does nothing for 2 seconds</p>
<p>Complicated animations can be build from simpler animations, all which are abstracted to the animation level.  In a rich, interactive environment, most objects will have some sort of roll-over effect and many will share similar roll-over effects, this will make managing and creating these effects easy.</p>
<p>Part 4: Implementation</p>
<p>An animation will essentially be a tree that knows how to invoke it&#8217;s children</p>
<p>Every different action listen above will be a different node type.  It will set the node that it was called from as the child.  For example tween1.attach(div) creates an &#8216;attachment node&#8217; that has tween1 as a child.  $tween.and(tween1, tween2) will create an &#8216;and node&#8217; that has both tween1 and tween2 as it&#8217;s children.</p>
<p>Each object will have a trigger(params) function and an animate(i, params).  The params object is used to pass information on to a nodes children.  &#8216;i&#8217; is used to represent how far along an animation is between 0.0 and 1.0.  </p>
<p>Calling go() on a tween instance will call that nodes trigger() method</p>
<p>A call on trigger() or animate(i) on a specific node does one of<br />
1) modifies params and calls the node&#8217;s child<br />
2) branches the single trigger() or animate() call to multiple trigger() or animate() calls<br />
3) modifies the i parameter</p>
<p>Here we explain how each node is used and created and how they do one of the above 3 actions:</p>
<p>BASIC NODES:</p>
<p>Tween.attr: created using $tween({attr: value});<br />
This is pretty much the basic animator, it only knows a single CSS<br />
attribute and either a modifier or a final value.  An identity node<br />
exists too that simply returns true always.  Because it is the basic<br />
animator it is less flexible.<br />
trigger() &#8211; trigger cannot be called on this node since it doesn&#8217;t<br />
have a duration or a dom element.<br />
animate(i, div = null) &#8211; i always represents a<br />
value between 0 and 1 that is how far along this single animation<br />
should be.  div must be a single dom element.  Animate modifies an<br />
elements css attributes based on the inital value that it looks up,<br />
the final modification necessary and the percentage of this that<br />
should be done.</p>
<p>Tween.duration: created using [tween].forSeconds(value)<br />
This is what converts a trigger() call into an animate() call and<br />
therefore creates a percentage based context for it&#8217;s child.<br />
trigger(params) &#8211; first calls it&#8217;s child with animate(0, div?) &#8211; if<br />
there is a div parameter in params it is passed on to the animate<br />
call.  If params has a callback parameter then this is called after<br />
the animation is done (to deal with &#8216;then&#8217;s).  If params has an ease<br />
parameter than this is used to modify i before it&#8217;s passed down (a<br />
linear ease could be modified to parabolic)<br />
animate(i) &#8211; an error should be thrown in this case.  this means that<br />
two intervals have been set which doesn&#8217;t have an inuitive meaning.</p>
<p>Tween.attach: created using [tween].attach(value . . . )<br />
This is what is responsible for attaching an animation to a DOM<br />
selector.  The value passed in on instantiation may represent many<br />
elements, this breaks that up into multiple animations<br />
trigger(params) &#8211; Calls trigger(params) on it&#8217;s child setting the div<br />
parameter to every DOM item that is selected using &#8216;value&#8217;.  If there<br />
is already a div parameter in params it throws an error<br />
animate(i) &#8211; Calls animate(i, div) where div is every unique DOM item<br />
that was selected using &#8216;value&#8217;.  If called with two arguments, throws<br />
and error</p>
<p>&#8212;&#8212;</p>
<p>ACCESSORY NODES:</p>
<p>Tween.and: created using $tween.and(value, value . . .)<br />
This is doing two animations at the same time<br />
trigger(params) &#8211; Calls trigger(params)on both it&#8217;s children.<br />
animate(i, params) &#8211; Calls animate(i, params) on both it&#8217;s children</p>
<p>Tween.then: created using $tween.then(value, value . . .)<br />
This is doing one animation and then another<br />
trigger(params) &#8211; Calls trigger(params) on first child, setting a<br />
callback param that is a function that calls trigger(params) onto<br />
second animation etc.  If params already has a callback parameter then<br />
this callback should be called first, and then the second parameter.<br />
animate(i, params) &#8211; If this is called it means that the children do<br />
not have durations and just assumes that they all get equal parts of<br />
the animation.  If n = the amount of values passed in, then just calls<br />
first child&#8217;s animate(i, params) on the first child for values of i &lt;<br />
1/n, calls animate(i, params) on the second child if 1/n &lt; i &lt; 2/n etc</p>
<p>Tween.repeat: created using [tween].repeat(value)<br />
This simply does the same as [tween].then except the callback</p>
<p>Tween.pause(value): created using $tween.pauseForSeconds(value)<br />
essentially creates an tween that does nothing for &#039;value&#039; seconds<br />
return $tween().forSeconds(value);</p>
<p>Tween.ease(value): created using [tween].ease(value)<br />
This adds an easing capability to tweens.  It will have preset values<br />
that can be passed in such as &#039;gravity&#039; or &#039;slide&#039;.  It should know<br />
how to convert a &#039;linear&#039; value between 0 and 1 to an eased value<br />
trigger(params) &#8211; adds a function that knows how to modify i to the<br />
ease paramater of params.  If &#039;ease&#039; already exists throws error.<br />
animate(i, params) &#8211; simply modifies i to the new value and calls child.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cs164projects39.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cs164projects39.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cs164projects39.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cs164projects39.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cs164projects39.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cs164projects39.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cs164projects39.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cs164projects39.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cs164projects39.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cs164projects39.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cs164projects39.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cs164projects39.wordpress.com/39/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cs164projects39.wordpress.com/39/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cs164projects39.wordpress.com/39/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cs164projects39.wordpress.com&amp;blog=10602032&amp;post=39&amp;subd=cs164projects39&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cs164projects39.wordpress.com/2009/12/19/write-up-parts-3-and-4/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42862d722292de8680cf703d399ae960?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cs164projects39</media:title>
		</media:content>
	</item>
		<item>
		<title>Project Write-Up: Parts 1 and 2</title>
		<link>http://cs164projects39.wordpress.com/2009/12/19/project-write-up-parts-1-and-2/</link>
		<comments>http://cs164projects39.wordpress.com/2009/12/19/project-write-up-parts-1-and-2/#comments</comments>
		<pubDate>Sat, 19 Dec 2009 07:44:39 +0000</pubDate>
		<dc:creator>cs164projects39</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cs164projects39.wordpress.com/?p=31</guid>
		<description><![CDATA[Part 1: Our project initially aimed to be a small javascript toolkit (along the lines of jQuery, but likely with less features), but we've since changed our goal to provide a simple toolkit for animating DOM elements on a web page. This will be helpful for web developers who need a middle ground between a [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cs164projects39.wordpress.com&amp;blog=10602032&amp;post=31&amp;subd=cs164projects39&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<pre><span style="font-size:10px;">
<div id="_mcePaste">Part 1:

Our project initially aimed to be a small javascript toolkit (along the lines of jQuery, but
likely with less features), but we've since changed our goal to provide a simple toolkit for
animating DOM elements on a web page. This will be helpful for web developers who need a middle
ground between a dynamic website with javascript and full-on flash for animation, and it will
provide a simple interface, as its target audience is web developers.

Doing animation in javascript is possible, but quite tedious. A web developer will not want to
deal with setting timeouts and calculating durations and intermediate values in an animation.
One way we aim to simplify this task is by defining "tweens", which is I believe a flash
terminology for an animation where the developer specifies a value to update (such as a div's
width) and the amount to change it by, and the time-span, and the "tween" code will handle
all of the nitty-gritty details.

Why solve this problem? There is indeed an existing solution for jQuery (our solution also will
leverage jQuery's extant, and quite effective, means of manipulating the DOM), but it is quite
simple. The jQuery animation tool is a quick and easy way to alter the CSS attributes of
individual elements in isolation, but it doesn't provide a way to coordinate the animation of
multiple elements. This is exactly what we aim to do—provide an intuitive means of composing
animations of multiple elements.

Part 2:

Since we've already compared our project to the jQuery toolkit's animation tool, I'll describe
how they built their library; the internals of our code are set up in a similar manner.

At the core of jQuery is the "$" function, which returns a jQuery object. It takes a selector,
which can be a variety of things: something to identify a DOM element by CSS properties (e.g.
an equivalent to getElementById) or tag name, a DOM element object itself, or some other rarer
cases.

An example of jQuery code:
$(document).ready(function() {
  $("div").css({'backgroundColor':'blue'}).append("&lt;img src=\"blah\"/&gt;").show();
});

This example demonstrates two types of jQuery selectors. The first passes the javascript object
"document" to the "$" function, and registers an anonymous function to run when the document's
ready event fires. The second call, within the anonymous function, selects all div elements in
the HTML document, changes the background color to blue via CSS, creates an image and appends
it within every div, and then shows the divs (which were perhaps previously hidden with
"hide()").

The implementation of jQuery is, from a high level, fairly simple. It creates an object, called
jQuery, as a function, and all functionality is programmed into this object. It contains all of
the convenience methods of jQuery, which themselves encapsulate handling browser quirks and
whatnot. jQuery also includes its own CSS selection engine for filtering and running regexes
on the page's style sheets. One interesting aspect of the implementation is that the jQuery
object has an "extend" function that can be used to add new fields and methods to the
object, and this method is used to modularize the library—for example, AJAX support and
animations are included via this type of extension. The library is then made accessible
by defining a new field in the existing javascript "window" object—the jQuery object is
assigned to and called by "window.$".

To get an idea of what this looks like, here's some boiled down pseudocode.

var jQuery = window.$ = function(selector) {
  return new jQuery.prototype.init(selector)
}

jQuery.prototype = {
  init: function(selector) { ... },
  attr: function ( ... ) { //either get or set HTML attribute values. },
}
jQuery.extend = jQuery.prototype.extend = function() {
  // do some copying.
}
jQuery.extend({
  ajax: function( ... ) { //do ajax stuff! },
  ...
});

An example for the Animate tool (http://docs.jquery.com/Effects/animate) that shows composition
of animations (but only on a single element!) is shown below:

$("#go2").click(function(){
  $("#block2").animate( { width:"90%"}, 1000 )
     .animate( { fontSize:"24px" } , 1000 )
     .animate( { borderLeftWidth:"15px" }, 1000);
});</div>

</span></pre>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cs164projects39.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cs164projects39.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cs164projects39.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cs164projects39.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cs164projects39.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cs164projects39.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cs164projects39.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cs164projects39.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cs164projects39.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cs164projects39.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cs164projects39.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cs164projects39.wordpress.com/31/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cs164projects39.wordpress.com/31/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cs164projects39.wordpress.com/31/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cs164projects39.wordpress.com&amp;blog=10602032&amp;post=31&amp;subd=cs164projects39&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cs164projects39.wordpress.com/2009/12/19/project-write-up-parts-1-and-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42862d722292de8680cf703d399ae960?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cs164projects39</media:title>
		</media:content>
	</item>
		<item>
		<title>Additions and Clarifications to $tween</title>
		<link>http://cs164projects39.wordpress.com/2009/12/13/additions-and-clarifications-to-tween/</link>
		<comments>http://cs164projects39.wordpress.com/2009/12/13/additions-and-clarifications-to-tween/#comments</comments>
		<pubDate>Sun, 13 Dec 2009 22:41:56 +0000</pubDate>
		<dc:creator>cs164projects39</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cs164projects39.wordpress.com/?p=25</guid>
		<description><![CDATA[Some questions we had: 1)      It was not clear to me whether you plan to embed this language in javascript, or in jquery or in the 164 language. We plan on embedding this language into javascript.  The purpose of $tween is not to define new semantics for selecting components, therefore jQuery will still be an [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cs164projects39.wordpress.com&amp;blog=10602032&amp;post=25&amp;subd=cs164projects39&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Some questions we had:</p>
<p>1)      It was not clear to me whether you plan to embed this language in javascript, or in jquery or in the 164 language.</p>
<p>We plan on embedding this language into javascript.  The purpose of $tween is not to define new semantics for selecting components, therefore jQuery will still be an integral part of the language.</p>
<p>2)      Please examine the jquery function animate (<a href="http://docs.jquery.com/Effects/animate" target="_blank">http://docs.jquery.com/Effects/animate</a>) and argue why your solution is nicer.</p>
<p>We believe that our $tween language is much simpler than jQuery&#8217;s &#8220;animate&#8221; function because of a few reasons:</p>
<p>1 &#8211; $tween allows re-use of animations.  Once you define bounce() you can arbitrarily apply it to any part of the dom or compose it with other animations</p>
<p>2- $tween allows composition of animations.</p>
<p>Implementation Details:</p>
<p>There are two steps to animating a dom element.</p>
<p>1 &#8211; Define the animation</p>
<p>2 &#8211; Attach the animation</p>
<p>For example here are three applications that we&#8217;d like to be able to run in the final language:</p>
<p>A simple program showing concatenation.  On clicking the button the div box will simultaneously grow from 100px by 100px to 200px by 140px.</p>
<blockquote><p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script src=&#8221;http://code.jquery.com/jquery-latest.js&#8221;&gt;&lt;/script&gt;</p>
<p>&lt;script&gt;</p>
<p>$(document).ready(function(){</p>
<p>var growWidth = $tween.scaleWidth(&#8220;200px&#8221;);<br />
var growHeight = $tween.scaleHeight(&#8220;1.4x&#8221;);<br />
var growBoth = growWidth.and().growHeight;</p>
<p>(&#8220;#go&#8221;).click(function(){<br />
growBoth(&#8220;#block&#8221;);<br />
});</p>
<p>&lt;/script&gt;<br />
&lt;style&gt;<br />
div {<br />
background-color:#bca;<br />
height:100px;<br />
width:100px;<br />
}<br />
&lt;/style&gt;</p>
<p>&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;button id=&#8221;go&#8221;&gt;» Run&lt;/button&gt;<br />
&lt;div id=&#8221;block&#8221;&gt;Hello!&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>A simple program showing general css property manipulation, animation reuse and composition.  Assuming that many of the engineers that will be animating a site will be the same engineers creating the initial CSS, we allow arbitrary animation of CSS properties.  Also, one div #a bounces left , dev #b bounces up, div #c bounces left and then bounces up, and finally dev #d bounces up and left concurrently</p>
<blockquote><p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script src=&#8221;http://code.jquery.com/jquery-latest.js&#8221;&gt;&lt;/script&gt;</p>
<p>&lt;script&gt;<br />
$(document).ready(function(){</p>
<p>var bounceLeft = $tween({&#8220;left&#8221;: &#8220;-=50px&#8221;)).bounce();<br />
var bounceUp = $tween({&#8220;top&#8221;: &#8220;-=50px&#8221;)).bounce();</p>
<p>bounceLeft(&#8220;#a&#8221;);<br />
bounceUp(&#8220;#b&#8221;);<br />
bounceLeft.and.bounceUp(&#8220;#c&#8221;);<br />
bounceLeft.then.bounceUp(&#8220;#d&#8221;);</p>
<p>});<br />
&lt;/script&gt;</p>
<p>&lt;style&gt;<br />
div {<br />
position:absolute;<br />
background-color:#abc;<br />
left:50px;<br />
top:50px;<br />
height:90px;<br />
width: 90px;<br />
}<br />
&lt;/style&gt;</p>
<p>&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;span id=&#8221;result&#8221;&gt; &lt;/span&gt;<br />
&lt;div id=&#8221;a&#8221; style=&#8221;background-color:blue;&#8221;&gt;&lt;/div&gt;<br />
&lt;div id=&#8221;b&#8221; style=&#8221;background-color:green;&#8221;&gt;&lt;/div&gt;<br />
&lt;div id=&#8221;c&#8221; style=&#8221;background-color:black;&#8221;&gt;&lt;/div&gt;<br />
&lt;div id=&#8221;d&#8221; style=&#8221;background-color:grey;&#8221;&gt;&lt;/div&gt;<br />
&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<p>Our final example program shows the complicated way that tweens can be composed.  One animation bounces the div, while the other one moves it down 200 px.  Both of these animations modify the &#8220;top&#8221; attribute, but $tween will be able to to both concurrently.</p>
<blockquote><p>&lt;html&gt;<br />
&lt;head&gt;<br />
&lt;script src=&#8221;http://code.jquery.com/jquery-latest.js&#8221;&gt;&lt;/script&gt;</p>
<p>&lt;script&gt;<br />
$(document).ready(function(){</p>
<p>var bounceUp = $tween({&#8220;top&#8221;: &#8220;-=20px&#8221;)).bounce(.5);<br />
var moveDown = $tween({&#8220;top&#8221;: &#8220;+=200px&#8221;}).linear(5);</p>
<p>$(&#8220;#moveAndBounce&#8221;).click(<br />
bounceUp.and.moveDown(&#8220;.block&#8221;);<br />
);</p>
<p>});<br />
&lt;/script&gt;<br />
&lt;style&gt;<br />
div {<br />
position:absolute;<br />
background-color:green;<br />
top:50px;<br />
width:90px;<br />
height:90px;<br />
}<br />
&lt;/style&gt;<br />
&lt;/head&gt;<br />
&lt;body&gt;<br />
&lt;button id=&#8221;moveAndBounce&#8221;&gt;move&lt;/button&gt;<br />
&lt;div&gt;&lt;/div&gt;</p>
<p>&lt;/body&gt;<br />
&lt;/html&gt;</p></blockquote>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cs164projects39.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cs164projects39.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cs164projects39.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cs164projects39.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cs164projects39.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cs164projects39.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cs164projects39.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cs164projects39.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cs164projects39.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cs164projects39.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cs164projects39.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cs164projects39.wordpress.com/25/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cs164projects39.wordpress.com/25/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cs164projects39.wordpress.com/25/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cs164projects39.wordpress.com&amp;blog=10602032&amp;post=25&amp;subd=cs164projects39&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cs164projects39.wordpress.com/2009/12/13/additions-and-clarifications-to-tween/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42862d722292de8680cf703d399ae960?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cs164projects39</media:title>
		</media:content>
	</item>
		<item>
		<title>Homework 3: JavaScript Toolkit</title>
		<link>http://cs164projects39.wordpress.com/2009/11/21/homework-3-javascript-toolkit/</link>
		<comments>http://cs164projects39.wordpress.com/2009/11/21/homework-3-javascript-toolkit/#comments</comments>
		<pubDate>Sat, 21 Nov 2009 07:07:06 +0000</pubDate>
		<dc:creator>cs164projects39</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://cs164projects39.wordpress.com/?p=3</guid>
		<description><![CDATA[Tweener Part 1: Problem being solved The aim of this project is very similar to that of the jQuery javascript toolkit. Toolkits like jQuery exist to ease programming for the web, which is tedious and unwieldy due to conflicting browser standards, ways of manipulating the DOM, and registering and handling events. Our goal is to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cs164projects39.wordpress.com&amp;blog=10602032&amp;post=3&amp;subd=cs164projects39&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h1 id="_mcePaste">Tweener</h1>
<h3>Part 1: Problem being solved</h3>
<div id="_mcePaste">
<p>The aim of this project is very similar to that of the jQuery javascript toolkit. Toolkits like jQuery exist to ease programming for the web, which is tedious and unwieldy due to conflicting browser standards, ways of manipulating the DOM, and registering and handling events. Our goal is to create a library for javascript that presents the programmer with a simple, consistent, and intuitive way to interact with an HTML/CSS document.</p>
</div>
<div id="_mcePaste">
<p>One example of ugly code that a javascript toolkit solves is doing browser checking to determine how to register events. These sorts of problems are common knowledge to web developers that must deal with them on a daily basis. To illustrate this, here&#8217;s a link to an article about the difficulty of writing a script that detects the cursor position upon an event:</p>
</div>
<div>
<p><a title="http://evolt.org/article/Mission_Impossible_mouse_position/17/23335/index.html" href="http://evolt.org/article/Mission_Impossible_mouse_position/17/23335/index.html" target="_blank">http://evolt.org/article/Mission_Impossible_mouse_position/17/23335/index.html</a></p>
</div>
<div id="_mcePaste">
<p>Hopefully, our language will provide a wraper for these obnoxious details, so the programmer can simply write something like &#8220;event.page_x&#8221;.</p>
</div>
<div id="_mcePaste">
<p>This problem is absolutely hard. As someone who has written javascript for web pages before, I can say that programming without toolkits is infinitely worse. One is constantly looking up W3C standards and browser support conflicts and wrangling with inconsistent syntax and obscure methods for manipulating the page elements. I think the profusion of javascript toolkits today is enough of a testament to the difficulty of this problem.</p>
</div>
<div id="_mcePaste">
<p>There&#8217;s no feasible way to circumvent this problem for a web developer. A web developer&#8217;s work must be as accessible as possible, meaning a potential user should not be required to have any special program to use a specific page—the web developer must ensure that his work supports all platforms and browsers. This means he must rely on existing languages and techniques for interacting with HTML and CSS, and the only one that is implemented in all web browsers is javascript.</p>
</div>
<div id="_mcePaste">
<h3>Part 2: A language that currently solves this problem</h3>
</div>
<div id="_mcePaste">
<p>Since we&#8217;ve already compared the goal of our project to the jQuery toolkit, I&#8217;ll describe that library.</p>
</div>
<div id="_mcePaste">
<p>At the core of jQuery is the &#8220;$&#8221; function, which returns a jQuery object. It takes a selector, which can be a variety of things: something to identify a DOM element by CSS properties (e.g. an equivalent to getElementById) or tag name, a DOM element object itself, or some other rarer cases.</p>
</div>
<div>
<div>
<p>An example of jQuery code:</p>
</div>
<blockquote>
<div>
<p>$(document).ready(function() {</p>
</div>
<div>
<p>$(&#8220;div&#8221;).css({&#8216;backgroundColor&#8217;:'blue&#8217;}).append(&#8220;&lt;img src=\&#8221;blah\&#8221;/&gt;&#8221;).show();</p>
</div>
<div>
<p>});</p>
</div>
</blockquote>
<div>
<p>This example demonstrates two types of jQuery selectors. The first passes the javascript object &#8220;document&#8221; to the &#8220;$&#8221; function, and registers an anonymous function to run when the document&#8217;s ready event fires. The second call, within the anonymous function, selects all div elements in the HTML document, changes the background color to blue via CSS, creates an image and appends it within every div, and then shows the divs (which were perhaps previously hidden with &#8220;hide()&#8221;).</p>
</div>
<div>
<div>
<p>The implementation of jQuery is, from a high level, fairly simple. It creates an object, called jQuery, as a function, and all functionality is programmed into this object. It contains all of the convenience methods of jQuery, which themselves encapsulate handling browser quirks and whatnot. jQuery also includes its own CSS selection engine for filtering and running regexes on the page&#8217;s style sheets. One interesting aspect of the implementation is that the jQuery object has an &#8220;extend&#8221; function that can be used to add new fields and methods to the object, and this method is used to modularize the library—for example, AJAX support and animations are included via this type of extension. The library is then made accessible by defining a new field in the existing javascript &#8220;window&#8221; object—the jQuery object is assigned to and called by &#8220;window.$&#8221;.</p>
</div>
<div>
<div>
<p>To get an idea of what this looks like, here&#8217;s some boiled down pseudocode.</p>
</div>
<blockquote>
<div>
<p>var jQuery = window.$ = function(selector) {</p>
</div>
<div>
<p>return new jQuery.prototype.init(selector)</p>
</div>
<div>
<p>}</p>
</div>
<div>
<p>jQuery.prototype = {</p>
</div>
<div>
<p>init: function(selector) { &#8230; },</p>
</div>
<div>
<p>attr: function ( &#8230; ) { //either get or set HTML attribute values. },</p>
</div>
<div>
<p>}</p>
</div>
<div>
<p>jQuery.extend = jQuery.prototype.extend = function() {</p>
</div>
<div>
<p>// do some copying.</p>
</div>
<div>
<p>}</p>
</div>
<div>
<p>jQuery.extend({</p>
</div>
<div>
<p>ajax: function( &#8230; ) { //do ajax stuff! },</p>
</div>
<div>
<p>&#8230;</p>
</div>
<div>
<p>});</p>
</div>
</blockquote>
<div>
<h3>Part 3: The features of &#8216;$tween&#8217;</h3>
</div>
<div>
<p>Our language will facilitate easy and clean animation within the dom.  This should mainly be for designers who want to add some extra visual effects to their web application layout.  It should be relatively easy to create interesting visual effects in an intuitive way.  Also, taking into consideration that this is primarily for designers, most defaults are for the &#8216;common use&#8217; scenario.  Also, with all the languages that front-end developers must remember, $tween should be as easy as possible.  In order to do this, <strong>order of adding attributes</strong> to a tween is not important and unless some sort of argument is required (such as scale), then default values will be provided if an attribute is added without ()</p>
</div>
<div>
<p>The easiest way seems to be to abstract the idea of a &#8216;tween&#8217; or animation, that could just be used as a callback function would be used.  For example a &#8216;pulse&#8217; tween could be defined</p>
</div>
<blockquote>
<div>
<p>var pulse = $tween.scale(1.2).bounce; //this creates a tween that will scale a dom element 1.2 times its size and back with a bounce-like effect</p>
</div>
</blockquote>
<div>
<p>and then if a certain link should pulse when clicked on simply add</p>
</div>
<blockquote>
<div>
<p>&lt;input type=&#8221;button&#8221; onclick=&#8221;pulse()&#8221; value=&#8221;Show alert box&#8221; /&gt;</p>
</div>
</blockquote>
<div>
<p>another example:</p>
</div>
<blockquote>
<div>
<p>var bounce = $tween.yLoc(20).bounce; //this creates a tween that moves a dom element up 20 pixels with a bounce-like effect</p>
</div>
</blockquote>
<div>
<p>and these two effects can be added together in many ways</p>
</div>
<blockquote>
<div>
<p>var bouncePausePulse = $tween.bounce.pause(1).pulse;</p>
</div>
<div>
<p>var bounceAndPulse = $tween.bounce.and.pulse;</p>
</div>
</blockquote>
<div>
<p>Complicated animations can be build from simpler animations, all which are abstracted to the animation level.  In a rich, interactive environment, most objects will have some sort of roll-over effect and many will share similar roll-over effects, this will make managing and creating these effects easy.</p>
</div>
<div>
<h3>Part 4: Implementation</h3>
</div>
<div>
<p>Creation takes the form of an identifier followed by a series of calls.  A tween object is created using the identifiers:</p>
</div>
<div>
<p>$tween.</p>
</div>
<div>
<p>The syntax will allow the designer to specify:</p>
</div>
<div>
<p>Which attribute to be animated:</p>
</div>
<div>
<p>yLoc(y) &#8211; the desired &#8216;y&#8217; location</p>
</div>
<div>
<p>xLoc(x) &#8211; the desired &#8216;x&#8217; location</p>
</div>
<div>
<p>scale(n) &#8211; the desired size of the item</p>
</div>
<div>
<p>(eventually we could incorporate background/foreground color, border animation, text size, opacity, etc)</p>
</div>
<div>
<p>Styles or &#8216;ease&#8217; of animation, with optional arguments for length of time:</p>
</div>
<div>
<p>&#8216;regular(n)&#8217; [default] &#8211; direct move from one position/size to another at a constant rate</p>
</div>
<div>
<p>&#8216;elastic(n)&#8217; &#8211; creates an elastic-like action (quick at first then slowing down)</p>
<p>&#8216;bounce(n)&#8217; &#8211; creates a bounce-like action (equivilant to an elastic movement followed by an elastic return)</p>
</div>
<div>
<p>&#8216;linear(n)&#8217; &#8211; tween at a constant rate</p>
</div>
<div>
<p>&#8216;instantly&#8217; &#8211; instantly move or scale</p>
</div>
<div>
<p>Concatenation operators for connecting tweens:</p>
</div>
<div>
<p>&#8216;pause(n)&#8217; &#8211; pause for a certain amount of time then continue</p>
</div>
<div>
<p>&#8216;repeat(n)&#8217; &#8211; repeat n times (leave out for infinite)</p>
</div>
<div>
<p>&#8216;then&#8217; &#8211; immediately follow previous tween (effectively a pause(0))</p>
</div>
<div>
<p>&#8216;and&#8217; &#8211; do the two tweens concurrently</p>
</div>
<div>
<p>And always allowing the item to return to the beginning locations with:</p>
</div>
<div>
<p>&#8216;$return&#8217; &#8211; a special tween that will with the original yLoc, xLoc and scale attributes</p>
</div>
<div>
<p>We envision there being two main types of objects</p>
</div>
<div>
<p>a tween &#8211; what the 2 &#8216;$&#8217; attributes return ($tween, and $return)</p>
</div>
<div>
<p>- this is actually a function, but will be seen as an animation, or tween, that can be added to any event</p>
</div>
<div>
<p>and</p>
</div>
<div>
<p>- a tween attribute &#8211; which is what all the other functions return</p>
</div>
<div>
<p>there may also be a wrapper class for concatenation operators so that operations such as &#8216;and.animation1&#8242; does not return a legal function</p>
</div>
<div>
<p>The internal representation will be a class that builds itself based on attributes added via function calls.  When the tween class receives this object, it will build the necessary callback function.</p>
</div>
<div>
<p>There will be no interpreter/compiler required, the processing will be building the tween object attribute object and then creating the necessary callback.</p>
</div>
<div>
<p>debugging can be done via the many JavaScript debuggers available.</p>
</div>
</div>
</div>
</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/cs164projects39.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/cs164projects39.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/cs164projects39.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/cs164projects39.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/cs164projects39.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/cs164projects39.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/cs164projects39.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/cs164projects39.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/cs164projects39.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/cs164projects39.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/cs164projects39.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/cs164projects39.wordpress.com/3/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/cs164projects39.wordpress.com/3/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/cs164projects39.wordpress.com/3/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=cs164projects39.wordpress.com&amp;blog=10602032&amp;post=3&amp;subd=cs164projects39&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://cs164projects39.wordpress.com/2009/11/21/homework-3-javascript-toolkit/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/42862d722292de8680cf703d399ae960?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cs164projects39</media:title>
		</media:content>
	</item>
	</channel>
</rss>
