
<?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>Bryce McDonnell &#124;&#124; Freelance Web Application Developer &#187; content slider</title>
	<atom:link href="http://www.brycemcdonnell.com/skills-and-expert-groups/content-slider/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.brycemcdonnell.com</link>
	<description>bryce mcdonnell is a freelance web application developer specializing in PHP, Ruby on Rails and MySQL</description>
	<lastBuildDate>Fri, 26 Feb 2010 18:18:48 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Improved Content Slider In MooTools</title>
		<link>http://www.brycemcdonnell.com/2009/05/improved-content-slider-in-mootools/</link>
		<comments>http://www.brycemcdonnell.com/2009/05/improved-content-slider-in-mootools/#comments</comments>
		<pubDate>Wed, 27 May 2009 20:00:54 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[HowTo]]></category>
		<category><![CDATA[Stuff I'm Working On]]></category>
		<category><![CDATA[content slider]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://blog.brycemcdonnell.com/?p=83</guid>
		<description><![CDATA[<a href=http://www.brycemcdonnell.com/2009/05/improved-content-slider-in-mootools/><img src=http://blog.thedevranch.net/wp-content/uploads/2009/05/BME-logo-small.jpg class=imgtfe hspace=5 align=left width=100  border=0></a>A little while ago, I posted some javascript for a mootools content slider. I&#8217;ve used it a lot in my own Ruby on Rails and PHP development work and my work with jv2 I have been itching to just drop it into my code like Squeezebox or Swfobject.
So, here it is, a fairly beta version [...]]]></description>
			<content:encoded><![CDATA[<p>A little while ago, I posted some javascript for a <a title="content slider in mootools" href="/mootools-content-slider-javascript/" target="_self">mootools content slider</a>. I&#8217;ve used it a lot in my own <a title="PHP and Ruby on Rails Developer" href="http://www.brycemcdonnell.com" target="_blank">Ruby on Rails and PHP development work</a> and my work with <a title="jv2 interactive and creative" href="http://www.jv2.com" target="_blank">jv2</a> I have been itching to just drop it into my code like <a title="mootools squeezebox" href="http://digitarald.de/project/squeezebox/" target="_blank">Squeezebox</a> or <a title="swfobject" href="http://blog.deconcept.com/swfobject/" target="_blank">Swfobject</a>.</p>
<p>So, here it is, a fairly beta version of a horizontal content slider written with the <a title="mootools" href="http://www.mootools.net/">Mootools</a> 1.2 framework. Simply <a title="download content slider class" onclick="pageTracker._trackEvent('downloads' , 'contentSlider')" href="/downloads/ContentSlider.js">download</a> (or copy and paste) the ContentSlider class into your page and then instantiate with the required arguments.</p>
<p><span id="more-83"></span></p>
<h2><strong>Usage Example:</strong></h2>
<p>the ContentSlider class</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #006600; font-style: italic;">/**
 * Content Slider - A Useable Horizontal Scroller
 *
 *  Requires a parent element with hidden overflow and child elements floated inside the parent.
 *  Take any two elements as previous and next buttons and scolls the child elements through the parent element
 *
 * Dependencies: MooTools 1.2 (and probably 1.1.x but not tested)
 *
 * adapted from Antonio Lupetti's original blog post at
 *    http://woork.blogspot.com/2009/01/elegant-animated-weekly-timeline-for.html
 *
 * @version		0.9
 *
 * @license		MIT-style license
 * @author		Bryce McDonnell bryce {at} bridgetownint {dot} com   www.brycemcdonnell.com
 * @copyright	Bryce McDonnell
 */</span>
<span style="color: #003366; font-weight: bold;">var</span> ContentSlider <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> <span style="color: #003366; font-weight: bold;">Class</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
    config<span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
		totIncrement<span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
		increment<span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
		maxRightIncrement<span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">,</span>
		container<span style="color: #339933;">:</span> $empty<span style="color: #339933;">,</span>
		slidingEl<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;&quot;</span><span style="color: #339933;">,</span>
		slideAtATime<span style="color: #339933;">:</span> 1<span style="color: #339933;">,</span>
		previous_btn<span style="color: #339933;">:</span> $empty<span style="color: #339933;">,</span>
		next_btn<span style="color: #339933;">:</span> $empty<span style="color: #339933;">,</span>
		duration<span style="color: #339933;">:</span> 1000<span style="color: #339933;">,</span>
		transition<span style="color: #339933;">:</span> Fx.<span style="color: #660066;">Transitions</span>.<span style="color: #000066;">Back</span>.<span style="color: #660066;">easeInOut</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	initialize<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>config<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span> <span style="color: #339933;">=</span> $merge<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span><span style="color: #339933;">,</span> config<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">maxRightIncrement</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">increment</span> <span style="color: #339933;">*</span> <span style="color: #339933;">-</span><span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span> $$<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">slidingEl</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">/</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">slideAtATime</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> 1 <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">previous_btn</span> <span style="color: #339933;">&amp;</span>amp<span style="color: #339933;">;&amp;</span>amp<span style="color: #339933;">;</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">next_btn</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">activateMoveBtns</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000066; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	move<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">fx</span> <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Fx.<span style="color: #660066;">Tween</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">container</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
		property<span style="color: #339933;">:</span> <span style="color: #3366CC;">'margin-left'</span><span style="color: #339933;">,</span>
		duration<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">duration</span><span style="color: #339933;">,</span>
		transition<span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">transition</span><span style="color: #339933;">,</span>
&nbsp;
		onStart<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">previous_btn</span>.<span style="color: #660066;">removeEvents</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">next_btn</span>.<span style="color: #660066;">removeEvents</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
&nbsp;
		onComplete<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">activateMoveBtns</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
&nbsp;
	activateMoveBtns<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #006600; font-style: italic;">//Next Button</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">next_btn</span>.<span style="color: #660066;">addEvents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #3366CC;">'click'</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">totIncrement</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">totIncrement</span><span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>this.<span style="color: #660066;">config</span>.<span style="color: #660066;">maxRightIncrement</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">totIncrement</span> <span style="color: #339933;">-</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">increment</span> <span style="color: #339933;">:</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
				event.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">move</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">fx</span>.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">totIncrement</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	 		<span style="color: #009900;">&#125;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>
&nbsp;
		 <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #006600; font-style: italic;">//Previous Button</span>
		<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">previous_btn</span>.<span style="color: #660066;">addEvents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
			<span style="color: #3366CC;">'click'</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">move</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				event.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">totIncrement</span> <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">totIncrement</span> <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> 0<span style="color: #009900;">&#41;</span> <span style="color: #339933;">?</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">totIncrement</span> <span style="color: #339933;">+</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">increment</span> <span style="color: #339933;">:</span> <span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">maxRightIncrement</span><span style="color: #339933;">;</span>
				<span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">fx</span>.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span>.<span style="color: #660066;">config</span>.<span style="color: #660066;">totIncrement</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
ContentSlider.<span style="color: #660066;">extend</span><span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">new</span> Fx.<span style="color: #660066;">Tween</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>html markup</p>

<div class="wp_syntax"><div class="code"><pre class="html" style="font-family:monospace;">&lt;script src=&quot;/lib/js/homeslider.js&quot; type=&quot;text/javascript&quot;&gt;&lt;!--mce:0--&gt;&lt;/script&gt;
&lt;div id=&quot;worksamples&quot; class=&quot;slide-box&quot;&gt;
	&lt;a id=&quot;slide-left&quot; class=&quot;slider-arrows&quot;&gt; previous &lt;/a&gt;
	&lt;a id=&quot;slide-right&quot; class=&quot;slider-arrows&quot;&gt;next&lt;/a&gt;
&lt;div id=&quot;workimgs&quot;&gt;
&lt;ul id=&quot;slider-list&quot;&gt;
	&lt;li&gt;&lt;img class=&quot;aligncenter size-full wp-image-168&quot; title=&quot;BME logo small&quot; src=&quot;http://blog.thedevranch.net/wp-content/uploads/2009/05/BME-logo-small.jpg&quot; alt=&quot;BME logo small&quot; width=&quot;300&quot; height=&quot;405&quot; /&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;/lib/img/slide/img.jpg&quot; alt=&quot;meth&quot; width=&quot;292&quot; height=&quot;184&quot; /&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;/lib/img/slide/img.jpg&quot; alt=&quot;nuskin&quot; width=&quot;292&quot; height=&quot;184&quot; /&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;/lib/img/slide/img.jpg&quot; alt=&quot;choice&quot; width=&quot;292&quot; height=&quot;184&quot; /&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;/lib/img/slide/img.jpg&quot; alt=&quot;meth&quot; width=&quot;292&quot; height=&quot;184&quot; /&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;/lib/img/slide/img.jpg&quot; alt=&quot;nuskin&quot; width=&quot;292&quot; height=&quot;184&quot; /&gt;&lt;/li&gt;
	&lt;li&gt;&lt;img src=&quot;/lib/img/slide/img.jpg&quot; alt=&quot;choice&quot; width=&quot;292&quot; height=&quot;184&quot; /&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;</pre></div></div>

<p>the javascript</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">new</span> ContentSlider<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
		increment<span style="color: #339933;">:</span> <span style="color: #CC0000;">904</span><span style="color: #339933;">,</span>
		container<span style="color: #339933;">:</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slider-list&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		slidingEl<span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;#slider-list li&quot;</span><span style="color: #339933;">,</span>
		slideAtATime<span style="color: #339933;">:</span> <span style="color: #CC0000;">3</span><span style="color: #339933;">,</span>
		next_btn<span style="color: #339933;">:</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slide-right&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
		previous_btn<span style="color: #339933;">:</span> $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slide-left&quot;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>the css markup:</p>

<div class="wp_syntax"><div class="code"><pre class="css" style="font-family:monospace;">  <span style="color: #808080; font-style: italic;">/***  SLIDER   ***/</span>
<span style="color: #cc00cc;">#worksamples</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">960px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">180px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#workimgs</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">900px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span>0 <span style="color: #993333;">auto</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#slider-list</span><span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">20000px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">:</span><span style="color: #933;">400px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#slider-list</span> li<span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">list-style</span><span style="color: #00AA00;">:</span><span style="color: #993333;">none</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin</span><span style="color: #00AA00;">:</span><span style="color: #cc66cc;">0</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-right</span><span style="color: #00AA00;">:</span><span style="color: #933;">5px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">padding</span><span style="color: #00AA00;">:</span><span style="color: #933;">2px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">292px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">200px</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #6666ff;">.slider-arrows</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">display</span><span style="color: #00AA00;">:</span><span style="color: #993333;">block</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">width</span><span style="color: #00AA00;">:</span><span style="color: #933;">18px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">height</span><span style="color: #00AA00;">:</span><span style="color: #933;">42px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">text-indent</span><span style="color: #00AA00;">:</span><span style="color: #933;">-9999px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">overflow</span><span style="color: #00AA00;">:</span><span style="color: #993333;">hidden</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">margin-top</span><span style="color: #00AA00;">:</span><span style="color: #933;">74px</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">cursor</span><span style="color: #00AA00;">:</span><span style="color: #993333;">pointer</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#slide-</span><span style="color: #000000; font-weight: bold;">left</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">left</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">../img/left-arrow.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> !important<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">../img/left-arrow.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
<span style="color: #00AA00;">&#125;</span>
<span style="color: #cc00cc;">#slide-</span><span style="color: #000000; font-weight: bold;">right</span> <span style="color: #00AA00;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">float</span><span style="color: #00AA00;">:</span><span style="color: #000000; font-weight: bold;">right</span><span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">../img/right-arrow.png</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span> !important<span style="color: #00AA00;">;</span>
	<span style="color: #000000; font-weight: bold;">background</span><span style="color: #00AA00;">:</span><span style="color: #993333;">url</span><span style="color: #00AA00;">&#40;</span><span style="color: #ff0000; font-style: italic;">../img/right-arrow.gif</span><span style="color: #00AA00;">&#41;</span> <span style="color: #993333;">no-repeat</span><span style="color: #00AA00;">;</span>
&nbsp;
<span style="color: #00AA00;">&#125;</span></pre></div></div>

<h2>Explanation:</h2>
<p>This serves as a pretty rudimentary example. The markup is simply a list with containing images that need scrolling. For the next and previous buttons, I got creative and got rid of the text and set an image for the background. That provides a good looking UI to the user.</p>
<p>Usage requires two basic elements: a container and child elements to scroll through. The parent should hide all overflow and the child elements should float so as to be one long horizontal array of scrolling elements. Simply include the class on any page and then instantiate the class passing in the required arguments.</p>
<h2>Arguments:</h2>
<p><strong>increment</strong> : the number of pixels the container should scoll. You could call $(&#8221;inner-el&#8221;).width here if you want to just scroll one element. I&#8217;m working on eliminating this requirement and instead just calculating it using the other arguments passed in.</p>
<p><strong>container</strong>: A reference to the parent element with hidden overflow</p>
<p><strong>slidingEl</strong>: collection of elements to scroll horizontally. Can be a css selector object</p>
<p><strong>slideAtATime</strong>: an integer passed in to indicate how many child elements to scroll at when either the previous or next buttons are pushed. defaults to 1</p>
<p><strong>next_btn</strong>: a reference to the element to scroll to the right. A click event is added to this element when the class is instantiated</p>
<p><strong>previous_btn</strong>: a reference to the element to scroll to the right. A click event is added to this element when the class is instantiated</p>
<h2>Closing:</h2>
<p>Happy MooTool&#8217;ing ! Be sure to post a comment if you see something wrong or would like to add to this.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brycemcdonnell.com/2009/05/improved-content-slider-in-mootools/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Mootools content slider &#8211; javascript</title>
		<link>http://www.brycemcdonnell.com/2009/03/mootools-content-slider-javascript/</link>
		<comments>http://www.brycemcdonnell.com/2009/03/mootools-content-slider-javascript/#comments</comments>
		<pubDate>Fri, 06 Mar 2009 00:32:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Stuff I'm Working On]]></category>
		<category><![CDATA[coding]]></category>
		<category><![CDATA[content slider]]></category>
		<category><![CDATA[HowTo]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[mootools]]></category>

		<guid isPermaLink="false">http://blog.brycemcdonnell.com/?p=77</guid>
		<description><![CDATA[
This is an old version of an improved Mootools Content Slider

I recently implemented a javascript based slider using MooTools. I&#8217;m increasingly becoming a huge fan of Mootools. Their documentation is great and the code I write just seems to be much cleaner. I don&#8217;t feel like it&#8217;s as fragile as js I&#8217;ve written in prototype/scriptaculous.
The [...]]]></description>
			<content:encoded><![CDATA[<div style="padding:20px; margin:10px; border:3px solid #FF0; background-color: #CCC">
<h2><span style="color: #000000;">This is an old version of an improved <a title="improved mootools content slider" href="http://blog.brycemcdonnell.com/improved-content-slider-in-mootools/">Mootools Content Slider</a></span></h2>
</div>
<p>I recently implemented a javascript based slider using <a href="http://mootools.net">MooTools</a>. I&#8217;m increasingly becoming a huge fan of <a href="http://mootools.net">Mootools</a>. Their <a href="http://mootools.net/docs">documentation</a> is great and the code I write just seems to be much cleaner. I don&#8217;t feel like it&#8217;s as fragile as js I&#8217;ve written in prototype/scriptaculous.</p>
<p>The content slider, which I pretty much implemented verbatim using <a href="http://woork.blogspot.com/2009/01/elegant-animated-weekly-timeline-for.html"><strong>Antonio Lupetti&#8217;s</strong></a> great tutorial at <a href="http://woork.blogspot.com/2009/01/elegant-animated-weekly-timeline-for.html">http://woork.blogspot.com/2009/01/elegant-animated-weekly-timeline-for.html</a>.</p>
<p>Antonio&#8217;s tutorial is really great. It is missing two elements which I think improve the code base:<span id="more-77"></span></p>
<p>1) you have to set the number of elements to scroll explicitly</p>
<p>2) it does not handle some crazy user clicking like mad on either the left or right buttons</p>
<p>To solve both those pains, I&#8217;ve updated the code a bit to work with MooTools 1.2 and made a couple of enhancements seen below.</p>

<div class="wp_syntax"><div class="code"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">var</span> totIncrement <span style="color: #339933;">=</span> <span style="color: #CC0000;">0</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> increment <span style="color: #339933;">=</span> <span style="color: #CC0000;">387</span><span style="color: #339933;">;</span>
<span style="color: #003366; font-weight: bold;">var</span> totalIncrements <span style="color: #339933;">=</span> $$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#sliderList li&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">length</span> <span style="color: #339933;">-</span> 1
<span style="color: #003366; font-weight: bold;">var</span> maxRightIncrement <span style="color: #339933;">=</span> increment<span style="color: #339933;">*</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span> totalIncrements<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">var</span> fx <span style="color: #339933;">=</span> <span style="color: #003366; font-weight: bold;">new</span> Fx.<span style="color: #660066;">Tween</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'sliderList'</span><span style="color: #339933;">,</span> <span style="color: #009900;">&#123;</span>
   property<span style="color: #339933;">:</span> <span style="color: #3366CC;">'margin-left'</span><span style="color: #339933;">,</span>
   duration<span style="color: #339933;">:</span> 1000<span style="color: #339933;">,</span>
   transition<span style="color: #339933;">:</span> Fx.<span style="color: #660066;">Transitions</span>.<span style="color: #000066;">Back</span>.<span style="color: #660066;">easeInOut</span><span style="color: #339933;">,</span>
   onStart<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slide-left&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeEvents</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;slide-right&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">removeEvents</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'click'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
   onComplete<span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      appEvent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #003366; font-weight: bold;">function</span> appEvent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
   <span style="color: #006600; font-style: italic;">// Previous Button</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slide-left'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addEvents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">'click'</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>totIncrement<span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span>0<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            event.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            totIncrement <span style="color: #339933;">=</span> totIncrement <span style="color: #339933;">+</span> increment<span style="color: #339933;">;</span>
            fx.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span>totIncrement<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #006600; font-style: italic;">// Next Button</span>
   $<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">'slide-right'</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">addEvents</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>
      <span style="color: #3366CC;">'click'</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
         <span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>totIncrement<span style="color: #339933;">&amp;</span>gt<span style="color: #339933;">;</span>maxRightIncrement<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            event.<span style="color: #000066;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            totIncrement <span style="color: #339933;">=</span> totIncrement <span style="color: #339933;">-</span> increment<span style="color: #339933;">;</span>
            fx.<span style="color: #660066;">start</span><span style="color: #009900;">&#40;</span>totIncrement<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
   <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
appEvent<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>By encapsulating the right and left click events into its own function, I can easily turn on and off the events to prevent the end user from invoking the slide event in the middle of an event that may already be going on. A shorter way to say that is users can&#8217;t double click.</p>
<p>Secondly, creating the totalIncrements variable allows someone (like me) to add another list element into the markup at a later date without having to remember to update the javascript code.</p>
<p>These are just a couple of tweaks to an otherwise great tutorial. Thanks a lot Antonio and keep up the good work.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.brycemcdonnell.com/2009/03/mootools-content-slider-javascript/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
