<?xml version="1.0" encoding="UTF-8"?><rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
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:series="http://unfoldingneurons.com/"
> <channel><title>Comments on: Create a Simple Slideshow Using MooTools, Part III: Creating a&#160;Class</title> <atom:link href="http://davidwalsh.name/create-a-simple-slideshow-iii/feed" rel="self" type="application/rss+xml" /><link>http://davidwalsh.name/create-a-simple-slideshow-iii</link> <description>Legendary scribbles about JavaScript, HTML5, AJAX, PHP, CSS, and ∞.</description> <lastBuildDate>Tue, 22 May 2012 05:31:04 +0000</lastBuildDate> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.2</generator> <item><title>By: Zod</title><link>http://davidwalsh.name/create-a-simple-slideshow-iii#comment-31331</link> <dc:creator>Zod</dc:creator> <pubDate>Thu, 29 Mar 2012 08:18:28 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4563#comment-31331</guid> <description>The code above is all broken, so i give you only the modified parts, do this:In &quot;options&quot;, find:&lt;code&gt;
showDuration: 3000,
&lt;/code&gt;and replace with:&lt;code&gt;
showDuration: 5000,
fadeDuration: 3000,
&lt;/code&gt;Then in &quot;initialize&quot;, find:&lt;code&gt;
if(i &gt; 0) el.set(&#039;opacity&#039;,0);
&lt;/code&gt;and replace with:&lt;code&gt;
if(i &gt; 0) el.set(&#039;opacity&#039;,0).setStyle(&#039;visibility&#039;, null);
&lt;/code&gt;now about fading transitions go in &quot;show&quot; function and find:&lt;code&gt;
.fade(&#039;out&#039;);
&lt;/code&gt;and replace with:&lt;code&gt;
.set(&#039;tween&#039;, {duration: this.options.fadeDuration}).tween(&#039;opacity&#039;, 1, 0);
&lt;/code&gt;then find:&lt;code&gt;
.fade(&#039;in&#039;);
&lt;/code&gt;and replace with:&lt;code&gt;
.set(&#039;tween&#039;, {duration: this.options.fadeDuration}).tween(&#039;opacity&#039;, 0, 1);
&lt;/code&gt;Then, the following part is optional, if you want the slideshow always running with mouse over (like i do), comment or remove this part:&lt;code&gt;
this.container.addEvents({
mouseenter: function() { this.stop(); }.bind(this),
mouseleave: function() { this.start(); }.bind(this)
});
&lt;/code&gt;Doing so, you need to fix the buttons, adding  &lt;code&gt; this.start(); &lt;/code&gt; at the end of the click event. I show you in the following parts:&lt;code&gt;
click: function(e) {
if(e) e.stop();
this.stop();
this.show(i);
this.start();
}.bind(this)
&lt;/code&gt;...then...&lt;code&gt;
click: function(e) {
if(e) e.stop();
this.stop();
this.show();
this.start();
}.bind(this)
&lt;/code&gt;...and finally this...&lt;code&gt;
click: function(e) {
if(e) e.stop();
this.stop();
this.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);
this.start();
}.bind(this)
&lt;/code&gt;That&#039;s all. Now i hope this code will show better... cross fingers ;).</description> <content:encoded><![CDATA[<p>The code above is all broken, so i give you only the modified parts, do this:</p><p>In &#8220;options&#8221;, find:</p><p><code><br
/> showDuration: 3000,<br
/> </code></p><p>and replace with:</p><p><code><br
/> showDuration: 5000,<br
/> fadeDuration: 3000,<br
/> </code></p><p>Then in &#8220;initialize&#8221;, find:</p><p><code><br
/> if(i &gt; 0) el.set('opacity',0);<br
/> </code></p><p>and replace with:</p><p><code><br
/> if(i &gt; 0) el.set('opacity',0).setStyle('visibility', null);<br
/> </code></p><p>now about fading transitions go in &#8220;show&#8221; function and find:</p><p><code><br
/> .fade('out');<br
/> </code></p><p>and replace with:</p><p><code><br
/> .set('tween', {duration: this.options.fadeDuration}).tween('opacity', 1, 0);<br
/> </code></p><p>then find:</p><p><code><br
/> .fade('in');<br
/> </code></p><p>and replace with:</p><p><code><br
/> .set('tween', {duration: this.options.fadeDuration}).tween('opacity', 0, 1);<br
/> </code></p><p>Then, the following part is optional, if you want the slideshow always running with mouse over (like i do), comment or remove this part:</p><p><code><br
/> this.container.addEvents({<br
/> mouseenter: function() { this.stop(); }.bind(this),<br
/> mouseleave: function() { this.start(); }.bind(this)<br
/> });<br
/> </code></p><p>Doing so, you need to fix the buttons, adding <code> this.start(); </code> at the end of the click event. I show you in the following parts:</p><p><code><br
/> click: function(e) {<br
/> if(e) e.stop();<br
/> this.stop();<br
/> this.show(i);<br
/> this.start();<br
/> }.bind(this)<br
/> </code></p><p>&#8230;then&#8230;</p><p><code><br
/> click: function(e) {<br
/> if(e) e.stop();<br
/> this.stop();<br
/> this.show();<br
/> this.start();<br
/> }.bind(this)<br
/> </code></p><p>&#8230;and finally this&#8230;</p><p><code><br
/> click: function(e) {<br
/> if(e) e.stop();<br
/> this.stop();<br
/> this.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);<br
/> this.start();<br
/> }.bind(this)<br
/> </code></p><p>That&#8217;s all. Now i hope this code will show better&#8230; cross fingers ;).</p> ]]></content:encoded> </item> <item><title>By: Zod</title><link>http://davidwalsh.name/create-a-simple-slideshow-iii#comment-31320</link> <dc:creator>Zod</dc:creator> <pubDate>Wed, 28 Mar 2012 20:08:16 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4563#comment-31320</guid> <description>Sorry for the bad text in my previous post, i had it well formatted in the textarea, not sure why it is so messy. :(</description> <content:encoded><![CDATA[<p>Sorry for the bad text in my previous post, i had it well formatted in the textarea, not sure why it is so messy. :(</p> ]]></content:encoded> </item> <item><title>By: Zod</title><link>http://davidwalsh.name/create-a-simple-slideshow-iii#comment-31319</link> <dc:creator>Zod</dc:creator> <pubDate>Wed, 28 Mar 2012 20:01:29 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4563#comment-31319</guid> <description>For Joe, and everybody who asked for a DURATION of the FADE effect. And of course for David if he wants to add my contribution in his original script.I played around with Mootools and Firebug, finally i found a solution (tested and working in Firefox, Chrome, Safari, IE7). More tests are welcome.
Sadly i noticed that Mootools does not support the &quot;duration&quot; in the function fade().  More in detail: the fade(&#039;in&#039;) function is working using the following code, but not the fade(&#039;out&#039;):&lt;code&gt;
.set(&#039;tween&#039;, {duration: 3000}).fade(&#039;in&#039;);
&lt;/code&gt;Fade out  just ignores the duration of the tween, and the opacity goes to &#039;0&#039; in no time (i wonder why).
So i thought to skip both functions and do them from scratches, using the tweens to change &quot;Opacity&quot;. A 3 seconds of transition like this:&lt;code&gt;
// instead of fade(&#039;out&#039;) i use this:
.set(&#039;tween&#039;, {duration: 3000}).tween(&#039;opacity&#039;, 1, 0);//instead of fade(&#039;in&#039;) i use this:
.set(&#039;tween&#039;, {duration: 3000}).tween(&#039;opacity&#039;, 0, 1);
&lt;/code&gt;These are working but i found some issues again. In Firebug i can see that the styles of the images have &quot;opacity&quot; and &quot;visibility&quot; attributes, so we have the annoying &quot;visibility:hidden&quot; that is messing up things. Actually the tweens are not setting &quot;visibility:visible&quot;, so the images never show up.So i fixed the behaviour modifying the code when David sets all images to &quot;opacity:0&quot;. I removed the visibility style, this way:&lt;code&gt;
if(i &gt; 0) el.set(&#039;opacity&#039;,0).setStyle(&#039;visibility&#039;, null);
&lt;/code&gt;I know it is not really smart to set both opacity and visibility, and then remove visibility, but this code is working for me.
So i finished the script adding my option &quot;fadeDuration&quot; together with the others, also, i added a start() function in the buttons, so the interval starts again after clicking (attention that in my code has little differences, i commented the &quot;mouseenter&quot; and &quot;mouseleave&quot; events, because i wanted the slideshow always running).And here is the final code, enjoy:&lt;code&gt;
var SimpleSlideshow = new Class({
options: {
showControls: true,
showDuration: 5000,
fadeDuration: 3000,
showTOC: true,
tocWidth: 20,
tocClass: &#039;toc&#039;,
tocActiveClass: &#039;toc-active&#039;
},
Implements: [Options,Events],
initialize: function(container,elements,options) {
//settings
this.container = $(container);
this.elements = $$(elements);
this.currentIndex = 0;
this.interval = &#039;&#039;;
if(this.options.showTOC) this.toc = [];
//assign
this.elements.each(function(el,i){
if(this.options.showTOC) {
this.toc.push(new Element(&#039;a&#039;,{
text: i+1,
href: &#039;#&#039;,
&#039;class&#039;: this.options.tocClass + &#039;&#039; + (i == 0 ? &#039; &#039; + this.options.tocActiveClass : &#039;&#039;),
events: {
click: function(e) {
if(e) e.stop();
this.stop();
this.show(i);
this.start();
}.bind(this)
},
styles: {
left: ((i + 1) * (this.options.tocWidth + 10))
}
}).inject(this.container));
}
if(i &gt; 0) el.set(&#039;opacity&#039;,0).setStyle(&#039;visibility&#039;, null);
},this);
//next,previous links
if(this.options.showControls) {
this.createControls();
}
//events
this.container.addEvents({
//mouseenter: function() { this.stop(); }.bind(this),
//mouseleave: function() { this.start(); }.bind(this)
});},
show: function(to) {
this.elements[this.currentIndex].set(&#039;tween&#039;, {duration: this.options.fadeDuration}).tween(&#039;opacity&#039;, 1, 0);
if(this.options.showTOC) this.toc[this.currentIndex].removeClass(this.options.tocActiveClass);
this.elements[this.currentIndex = ($defined(to) ? to : (this.currentIndex &gt;&#039;,
events: {
click: function(e) {
if(e) e.stop();
this.stop();
this.show();
this.start();
}.bind(this)
}
}).inject(this.container);
var previous = new Element(&#039;a&#039;,{
href: &#039;#&#039;,
id: &#039;previous&#039;,
text: &#039;&lt;&lt;&#039;,
events: {
click: function(e) {
if(e) e.stop();
this.stop();
this.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);
this.start();
}.bind(this)
}
}).inject(this.container);
}
});&lt;/code&gt;</description> <content:encoded><![CDATA[<p>For Joe, and everybody who asked for a DURATION of the FADE effect. And of course for David if he wants to add my contribution in his original script.</p><p>I played around with Mootools and Firebug, finally i found a solution (tested and working in Firefox, Chrome, Safari, IE7). More tests are welcome.<br
/> Sadly i noticed that Mootools does not support the &#8220;duration&#8221; in the function fade().  More in detail: the fade(&#8216;in&#8217;) function is working using the following code, but not the fade(&#8216;out&#8217;):</p><p><code><br
/> .set('tween', {duration: 3000}).fade('in');<br
/> </code></p><p>Fade out  just ignores the duration of the tween, and the opacity goes to &#8217;0&#8242; in no time (i wonder why).<br
/> So i thought to skip both functions and do them from scratches, using the tweens to change &#8220;Opacity&#8221;. A 3 seconds of transition like this:</p><p><code><br
/> // instead of fade('out') i use this:<br
/> .set('tween', {duration: 3000}).tween('opacity', 1, 0);</p><p>//instead of fade('in') i use this:<br
/> .set('tween', {duration: 3000}).tween('opacity', 0, 1);<br
/> </code></p><p>These are working but i found some issues again. In Firebug i can see that the styles of the images have &#8220;opacity&#8221; and &#8220;visibility&#8221; attributes, so we have the annoying &#8220;visibility:hidden&#8221; that is messing up things. Actually the tweens are not setting &#8220;visibility:visible&#8221;, so the images never show up.</p><p>So i fixed the behaviour modifying the code when David sets all images to &#8220;opacity:0&#8243;. I removed the visibility style, this way:</p><p><code><br
/> if(i &gt; 0) el.set('opacity',0).setStyle('visibility', null);<br
/> </code></p><p>I know it is not really smart to set both opacity and visibility, and then remove visibility, but this code is working for me.<br
/> So i finished the script adding my option &#8220;fadeDuration&#8221; together with the others, also, i added a start() function in the buttons, so the interval starts again after clicking (attention that in my code has little differences, i commented the &#8220;mouseenter&#8221; and &#8220;mouseleave&#8221; events, because i wanted the slideshow always running).</p><p>And here is the final code, enjoy:</p><p><code><br
/> var SimpleSlideshow = new Class({<br
/> options: {<br
/> showControls: true,<br
/> showDuration: 5000,<br
/> fadeDuration: 3000,<br
/> showTOC: true,<br
/> tocWidth: 20,<br
/> tocClass: 'toc',<br
/> tocActiveClass: 'toc-active'<br
/> },<br
/> Implements: [Options,Events],<br
/> initialize: function(container,elements,options) {<br
/> //settings<br
/> this.container = $(container);<br
/> this.elements = $$(elements);<br
/> this.currentIndex = 0;<br
/> this.interval = '';<br
/> if(this.options.showTOC) this.toc = [];</p><p> //assign<br
/> this.elements.each(function(el,i){<br
/> if(this.options.showTOC) {<br
/> this.toc.push(new Element('a',{<br
/> text: i+1,<br
/> href: '#',<br
/> 'class': this.options.tocClass + '' + (i == 0 ? ' ' + this.options.tocActiveClass : ''),<br
/> events: {<br
/> click: function(e) {<br
/> if(e) e.stop();<br
/> this.stop();<br
/> this.show(i);<br
/> this.start();<br
/> }.bind(this)<br
/> },<br
/> styles: {<br
/> left: ((i + 1) * (this.options.tocWidth + 10))<br
/> }<br
/> }).inject(this.container));<br
/> }<br
/> if(i &gt; 0) el.set('opacity',0).setStyle('visibility', null);<br
/> },this);</p><p> //next,previous links<br
/> if(this.options.showControls) {<br
/> this.createControls();</p><p> }<br
/> //events<br
/> this.container.addEvents({<br
/> //mouseenter: function() { this.stop(); }.bind(this),<br
/> //mouseleave: function() { this.start(); }.bind(this)<br
/> });</p><p> },<br
/> show: function(to) {<br
/> this.elements[this.currentIndex].set('tween', {duration: this.options.fadeDuration}).tween('opacity', 1, 0);<br
/> if(this.options.showTOC) this.toc[this.currentIndex].removeClass(this.options.tocActiveClass);<br
/> this.elements[this.currentIndex = ($defined(to) ? to : (this.currentIndex &gt;',<br
/> events: {<br
/> click: function(e) {<br
/> if(e) e.stop();<br
/> this.stop();<br
/> this.show();<br
/> this.start();<br
/> }.bind(this)<br
/> }<br
/> }).inject(this.container);<br
/> var previous = new Element('a',{<br
/> href: '#',<br
/> id: 'previous',<br
/> text: '&lt;&lt;&#039;,<br
/> events: {<br
/> click: function(e) {<br
/> if(e) e.stop();<br
/> this.stop();<br
/> this.show(this.currentIndex != 0 ? this.currentIndex -1 : this.elements.length-1);<br
/> this.start();<br
/> }.bind(this)<br
/> }<br
/> }).inject(this.container);<br
/> }<br
/> });</p><p></code></p> ]]></content:encoded> </item> <item><title>By: luca sabato</title><link>http://davidwalsh.name/create-a-simple-slideshow-iii#comment-26823</link> <dc:creator>luca sabato</dc:creator> <pubDate>Mon, 05 Sep 2011 17:28:34 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4563#comment-26823</guid> <description>i use mootools 1.3.2 compact and work out of box, very thanks!</description> <content:encoded><![CDATA[<p>i use mootools 1.3.2 compact and work out of box, very thanks!</p> ]]></content:encoded> </item> <item><title>By: Robert</title><link>http://davidwalsh.name/create-a-simple-slideshow-iii#comment-26821</link> <dc:creator>Robert</dc:creator> <pubDate>Mon, 05 Sep 2011 17:20:04 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4563#comment-26821</guid> <description>It can&#039;t be. I forgot to mention that it works fine on my VPS via Chrome but it doesn&#039;t work on my VPS and firefox. On my localhost it works in all browsers. It&#039;s very weird. I have never heard of a problem like this. Please help me, it&#039;s important.</description> <content:encoded><![CDATA[<p>It can&#8217;t be. I forgot to mention that it works fine on my VPS via Chrome but it doesn&#8217;t work on my VPS and firefox. On my localhost it works in all browsers. It&#8217;s very weird. I have never heard of a problem like this. Please help me, it&#8217;s important.</p> ]]></content:encoded> </item> <item><title>By: pSouper</title><link>http://davidwalsh.name/create-a-simple-slideshow-iii#comment-26820</link> <dc:creator>pSouper</dc:creator> <pubDate>Mon, 05 Sep 2011 16:40:19 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4563#comment-26820</guid> <description>or server settings dis-corelation (or php version)</description> <content:encoded><![CDATA[<p>or server settings dis-corelation (or php version)</p> ]]></content:encoded> </item> <item><title>By: pSouper</title><link>http://davidwalsh.name/create-a-simple-slideshow-iii#comment-26819</link> <dc:creator>pSouper</dc:creator> <pubDate>Mon, 05 Sep 2011 16:39:08 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4563#comment-26819</guid> <description>this may well be a path issue</description> <content:encoded><![CDATA[<p>this may well be a path issue</p> ]]></content:encoded> </item> <item><title>By: Robert</title><link>http://davidwalsh.name/create-a-simple-slideshow-iii#comment-26818</link> <dc:creator>Robert</dc:creator> <pubDate>Mon, 05 Sep 2011 16:31:30 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4563#comment-26818</guid> <description>I&#039;ve tried to integrate it with joomla. It works fine on my localhost now but it hangs if I put it on my VPS. What should I do?</description> <content:encoded><![CDATA[<p>I&#8217;ve tried to integrate it with joomla. It works fine on my localhost now but it hangs if I put it on my VPS. What should I do?</p> ]]></content:encoded> </item> <item><title>By: Joe</title><link>http://davidwalsh.name/create-a-simple-slideshow-iii#comment-26245</link> <dc:creator>Joe</dc:creator> <pubDate>Tue, 26 Jul 2011 18:50:39 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4563#comment-26245</guid> <description>Great tutorial, easily the most concise version I have seen in Part 1, brilliant work. I have definitely become a fan of your site.Part 2 and Part 3 examples do not seem to be working IE9 and running IE tester left a lot errors also. Any plans on fixing this to work cross platform?Part 1 worked fine in IE.After reading all 3 sections &amp; the comments it seems like many people are requesting duration controls for the speed of the fade in/out function. I think it would be a nice addition to your fantastic tutorial.Thank you David.</description> <content:encoded><![CDATA[<p>Great tutorial, easily the most concise version I have seen in Part 1, brilliant work. I have definitely become a fan of your site.</p><p>Part 2 and Part 3 examples do not seem to be working IE9 and running IE tester left a lot errors also. Any plans on fixing this to work cross platform?</p><p>Part 1 worked fine in IE.</p><p>After reading all 3 sections &amp; the comments it seems like many people are requesting duration controls for the speed of the fade in/out function. I think it would be a nice addition to your fantastic tutorial.</p><p>Thank you David.</p> ]]></content:encoded> </item> <item><title>By: Daquan Wright</title><link>http://davidwalsh.name/create-a-simple-slideshow-iii#comment-24457</link> <dc:creator>Daquan Wright</dc:creator> <pubDate>Sun, 19 Jun 2011 07:46:21 +0000</pubDate> <guid
isPermaLink="false">http://davidwalsh.name/?p=4563#comment-24457</guid> <description>David, I just want to say I am loving your blog right now! I have been turned over to mootools as I decided it is the perfect JS framework for me vs. any others, especially since I care about understanding JS.I love this code....so flexible and powerful! Thanks a ton.These slideshow tutorials rock.</description> <content:encoded><![CDATA[<p>David, I just want to say I am loving your blog right now! I have been turned over to mootools as I decided it is the perfect JS framework for me vs. any others, especially since I care about understanding JS.</p><p>I love this code&#8230;.so flexible and powerful! Thanks a ton.</p><p>These slideshow tutorials rock.</p> ]]></content:encoded> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced (User agent is rejected)
Database Caching 2/7 queries in 0.008 seconds using disk: basic
Object Caching 805/805 objects using disk: basic

Served from: davidwalsh.name @ 2012-05-22 03:10:23 -->
