<?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>dtsn &#187; Scriptaculous</title>
	<atom:link href="http://dtsn.co.uk/category/javascript/scriptaculous/feed/" rel="self" type="application/rss+xml" />
	<link>http://dtsn.co.uk</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Tue, 17 Aug 2010 13:18:57 +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>Bouncing JavaScript Tutorial</title>
		<link>http://dtsn.co.uk/2010/01/07/bouncing-javascript-tutorial/</link>
		<comments>http://dtsn.co.uk/2010/01/07/bouncing-javascript-tutorial/#comments</comments>
		<pubDate>Thu, 07 Jan 2010 11:00:38 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Scriptaculous]]></category>
		<category><![CDATA[Bounce]]></category>

		<guid isPermaLink="false">http://dtsn.co.uk/?p=692</guid>
		<description><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 3px 0px 0px 10px;">
			<br />
				<br />
			
		</div>
<p><strong>Original Source</strong>: http://giancarlo.dimassa.net</p>
<p>There have been&#8230;</p>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 3px 0px 0px 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdtsn.co.uk%2F2010%2F01%2F07%2Fbouncing-javascript-tutorial%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;source=dtsn&amp;style=normal&amp;service=is.gd&amp;hashtags=Bounce,JavaScript,Prototype,Scriptaculous&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>Original Source</strong>: <a href="http://giancarlo.dimassa.net/2007/07/11/elastic-and-bouncing-transitions-in-scriptaculous/">http://giancarlo.dimassa.net</a></p>
<p>There have been many examples of bouncing effects in <a href="http://script.aculo.us/">scriptaculous</a> but this one has to be one of the most realistic. It uses the equations developed by <a href="http://www.robertpenner.com/">Robert Penner</a> to accurately represent a bounce, and it does look cool.</p>
<h2>What you need</h2>
<p>As with most of my tutorials this is based on <a href="http://script.aculo.us/">scriptaculous</a> and <a href="http://www.prototypejs.org/">prototype</a>, but the equations could easily be porter to other animation frameworks.</p>
<h2>The code</h2>
<p>This is really simple, basically what we are going to be doing is to add a new transitional effect to scriptaculous. To do this we just extend the Effect class.</p>
<p><strong>Add this to your own JavaScript file instead of scriptaculous, so you don’t loose it when you update.</strong></p>
<pre class="js" name="code">/*Based on Easing Equations v2.0
(c) 2003 Robert Penner, all rights reserved.
This work is subject to the terms in http://www.robertpenner.com/easing_terms_of_use.html

Adapted for Scriptaculous by Ken Snyder (kendsnyder ~at~ gmail ~dot~ com) June 2006
*/

Effect.Transitions.Bounce = function (pos) {
    if (pos &lt; 0.36363636363636365) {
        return 7.5625 * pos * pos;
    } else if (pos &lt; 0.7272727272727273) {
        return 7.5625 * (pos -= 0.5454545454545454) * pos + 0.75;
    } else if (pos &lt; 0.9090909090909091) {
        return 7.5625 * (pos -= 0.8181818181818182) * pos + 0.9375;
    } else {
        return 7.5625 * (pos -= 0.9545454545454546) * pos + 0.984375;
    }
}</pre>
<h2>Use it</h2>
<p>You can use this effect as a transition type with lots of effects.</p>
<pre>new Effect.BlindDown(div, {
    duration: 0.5,
    transition: Effect.Transitions.Bounce
});</pre>
<p>Check out <a href="http://giancarlo.dimassa.net/2007/07/11/elastic-and-bouncing-transitions-in-scriptaculous/">Ken Snyder’s</a> blog for more transitional effects.</p>
]]></content:encoded>
			<wfw:commentRss>http://dtsn.co.uk/2010/01/07/bouncing-javascript-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JavaScript Halloween Effects</title>
		<link>http://dtsn.co.uk/2008/10/26/javascript-halloween-effects/</link>
		<comments>http://dtsn.co.uk/2008/10/26/javascript-halloween-effects/#comments</comments>
		<pubDate>Sun, 26 Oct 2008 22:40:00 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[CSS/HTML]]></category>
		<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Scriptaculous]]></category>

		<guid isPermaLink="false">http://dtsn.co.uk/?p=527</guid>
		<description><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 3px 0px 0px 10px;">
			<br />
				<br />
			
		</div>
<p>Halloween is just around the corner&#8230;</p>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 3px 0px 0px 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdtsn.co.uk%2F2008%2F10%2F26%2Fjavascript-halloween-effects%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;source=dtsn&amp;style=normal&amp;service=is.gd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p>Halloween is just around the corner and what better to jazz your blog up than with some Halloween related JavaScript. This tutorial will focus on making images appear and disappear on the background of your blog.</p>
<p>For this example I will be using a ghost which will appear every two seconds in a random location and disappear again. You can preview what this will look like by clicking the button below (<em>only viewable in a web browser</em>).</p>
<p>You can download the source files for this tutorial below as well as the ghost AI file.</p>
<input type="button" onclick="new Ghost();" value="Try Me" />
<p><a href="/wp-content/uploads/2008/10/Ghost.zip">Source Files</a></p>
<p>For this tutorial we are going to be using <a onclick="javascript:pageTracker._trackPageview(&#39;/outgoing/script.aculo.us/&#39;);" href="http://script.aculo.us/">Script.aculo.us</a> effects library with the <a onclick="javascript:pageTracker._trackPageview(&#39;/outgoing/ww.prototypejs.org&#39;);" href="http://ww.prototypejs.org">Prototype</a> core framework.</p>
<pre class="javascript" name="code">var Ghost = Class.create({
	initialize: function() {
	}
});</pre>
<p>First of all we need to create our Class, which is called <em>Ghost</em>. Inside the class <em>Ghost</em> we have added our initialize function. The initialize function will be called when we create a new instance of the class. Therefore we need to put in all our setup code:</p>
<pre class="javascript" name="code"> // create the element
this.ghost = new Element('div', {'class' : 'ghost'});
// hide the element
this.ghost.hide();
// add the element to the body
$(document.body).insert({top: this.ghost});
// get the size of the document
this.size = document.viewport.getDimensions();
// set up the timer
new PeriodicalExecuter(this.show.bindAsEventListener(this), 2);</pre>
<p>In this segment we create our hidden ghost element. We then store the size of the document, and load up our periodical executer to call <em>this.show</em>. The second parameter in the Periodical Executer is the time between calls, we are calling the show function once every 2 seconds.</p>
<pre class="javascript" name="code">show: function() {
	// randomly set where the ghost is going
	var x = Math.floor(Math.random()*(this.size['width']-200));
	var y = Math.floor(Math.random()*(this.size['height']-200));
	// set the style
	this.ghost.setStyle({
		'left': x + 'px',
		'top': y + 'px'
	});

	// show the object
	this.ghost.appear({
		afterFinish: function() {
			this.ghost.fade();
		}.bind(this)
	});
}</pre>
<p>The show function needs to be added to the <em>Ghost</em> class. The show function first calculates where we want our ghost to appear, so we work out random x and y co-ordinates using the document sizes we gathered in our initialize function. We then position the element and call the <a onclick="javascript:pageTracker._trackPageview(&#39;/outgoing/script.aculo.us/&#39;);" href="http://script.aculo.us/">Script.aculo.us</a> appear effect which will slowly fade in the image. After the appear effect has finish we want to hide the ghost so we call fade.</p>
<p>Ok, now we have all the code complete we need to call the class. We can do this in a number of ways, you could bind the event to a button:</p>
<pre class="html" name="code">
<div onclick="new Ghost()">BOO</div>
</pre>
<p>Or you can bind it into your document load function, which means it will start when the page loads:</p>
<pre class="javascript" name="code">document.observe("dom:loaded", function() {
	new Ghost();
});</pre>
<h3>CSS</h3>
<p>The CSS is a really simple one line.</p>
<pre class="css" name="code">.ghost { width: 100px; height: 100px; position: absolute; background: url('yourimage.png') no-repeat; }</pre>
<p>This tutorial is just a brief outline with what you can do with JavaScript this Halloween. If you have any other ideas you would like me to implement, please tell me in the comments below.</p>
]]></content:encoded>
			<wfw:commentRss>http://dtsn.co.uk/2008/10/26/javascript-halloween-effects/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Scriptaculous ScrollTo</title>
		<link>http://dtsn.co.uk/2008/03/14/scriptaculous-scrollto-tutorial/</link>
		<comments>http://dtsn.co.uk/2008/03/14/scriptaculous-scrollto-tutorial/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 05:22:44 +0000</pubDate>
		<dc:creator>daniel</dc:creator>
				<category><![CDATA[JavaScript]]></category>
		<category><![CDATA[Scriptaculous]]></category>

		<guid isPermaLink="false">http://www.dtsn.co.uk/2008/03/14/scriptaculous-scrollto-tutorial/</guid>
		<description><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 3px 0px 0px 10px;">
			<br />
				<br />
			
		</div>
<p><strong>Example: Click Here!</strong></p>
<p>The script.aculo.us effects&#8230;</p>]]></description>
			<content:encoded><![CDATA[<div class="tweetmeme_button" style="float: right; margin: 3px 0px 0px 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fdtsn.co.uk%2F2008%2F03%2F14%2Fscriptaculous-scrollto-tutorial%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif&amp;source=dtsn&amp;style=normal&amp;service=is.gd&amp;b=2" height="61" width="50" /><br />
			</a>
		</div>
<p><strong>Example: <a href="#" onclick="scroll.bottom()">Click Here!</a></strong></p>
<p>The <a href="http://script.aculo.us/">script.aculo.us</a> effects library is a fantastic tool. If this really simple tutorial I will show you how to utilize the <a href="http://wiki.script.aculo.us/scriptaculous/show/Effect.ScrollTo">scroll method</a> and a handy &#8216;jump to top link&#8217;.</p>
<h2>Step 1: Add References</h2>
<p>Make sure you have the <a href="http://prototypejs.org">prototype</a> and <a href="http://script.aculo.us/">script.aculo.us</a><br />
libraries attached to your web page, instructions for how to do this can be found <a href="http://wiki.script.aculo.us/scriptaculous/show/Usage">here</a>.</p>
<h2>Step 2: Create JavaScript</h2>
<p>You can either create a new JavaScript file or append these functions to an already existing one. So first of all we need the function. For that we create a new JavaScript object, we will call this &#8217;scroll&#8217;.</p>
<pre name="code" class="javascript">
var  scroll = { }
</pre>
<p>Next we want to add the functions. In my case I want a function that will scroll to the top and to the bottom:</p>
<pre name="code" class="javascript">
var  scroll = {
	top: function(event) {  },
	bottom: function(event) {  }
}
</pre>
<p>Now we have our framework we can call the ScrollTo function:</p>
<pre name="code" class="javascript">
new Effect.ScrollTo('top');
</pre>
<p>The ScrollTo function allows you to define a particular object that you want to scroll into view. In the case of dtsn.co.uk, I have a div on the top of every page with the ID of &#8216;top&#8217;.</p>
<p>Putting that all together we get:</p>
<pre name="code" class="javascript">
var  scroll = {
	top: function(event) { new Effect.ScrollTo('top'); },
	bottom: function(event) { new Effect.ScrollTo('footer'); }
}
</pre>
<p>You can then call this function in one of two ways. You can call &#8217;scroll.top()&#8217; and &#8217;scroll.bottom()&#8217;, respectively, through the onclick method on any HTML object. Alternative you can use the prototype method of <a href="http://prototypejs.org/api/event/observe">Event.Observe</a>:</p>
<pre name="code" class="javascript">
// wait for the page to load
Event.observe(document, 'load', function(){
        // give an object an onclick method
	$('go_to_top').observe('click', scroll.top);
});
</pre>
<p><script type="text/javascript">
   var  scroll = {
       bottom: function(event) { new Effect.ScrollTo($(document.body).select('ul.footer')[0]); }
   }
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://dtsn.co.uk/2008/03/14/scriptaculous-scrollto-tutorial/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>

