Thanks Ryan.

That wasn't quite what I was after.  Your code makes it loop in
reverse order whereas what I wanted was it just to go back just by 1
"slide" then continue foward as before.  I probably didn't explain
myself very clearly :(

Anyway, I got it working by doing, as you said in that, rather than
modifying the loop class, I added new methods to the class that
implemented it.

I am using a variation of your slideshow (removed the side labels for
my needs) so that is the class that I adjusted.  If it is of any use
to any body, I have put up a demo here: http://mooshell.net/nTLZq/2

These are the methods that I added for "back" and "next" controls:

 // move forward one item and reset timer
    loop_next:function(){
        $clear(this.periodical);
        this.periodical = this.looper.periodical
(this.options.delay,this);
        var nextIndex = (this.currentIndex == this.slides.length-1) ?
0 : this.currentIndex + 1;
        this.show(nextIndex);
        return this;
    },
    // move back one item and reset timer
    loop_prev: function(delay){
        $clear(this.periodical);
        this.periodical = this.looper.periodical
(this.options.delay,this);
        var nextIndex = (this.currentIndex == 0) ?
this.slides.length-1 : this.currentIndex - 1;
        this.show(nextIndex);
        return this;
    }

Once again, great stuff Ryan, thanks to your demos I feel that I am
finally beginning to understand classes (don't laugh)

Chris


On 9 nov, 04:44, Ryan Florence <[email protected]> wrote:
> You shouldn't have to touch Loop, just adjust your class that  
> implements it (though I did add one line to the setLoop method, so you  
> might want to download it here:http://moodocs.ryanflorence.com/RpFlo/Loop)
> .
>
> 1) Write a previous method in your implementing class that works with  
> Loop, just like the next method worked without the looping.
>
> 2) Call `myInstance.setLoop(this.previous, 500)`, or whatever delay  
> you want, and it will now loop your previous method.
>
> 3) If you're relying on `this.loopCount`, just drop in `this.loopCount  
> = count - 2` in your previous method to increment it negatively.
>
> Check out the new test:
>
> http://ryanflorence.com/scripts/mootools/Loop/test/
>
> Ryan Florence
>
> [Writing TextMate Snippets] (http://blog.flobro.com/)
>
> On Nov 8, 2009, at 4:24 PM, cbolson wrote:
>
>
>
> > Thanks Ryan, I shall be waiting patiently :)
>
> > On 8 nov, 23:47, Ryan Florence <[email protected]> wrote:
> >> I've been thinking of doing something like that.  I'll take a look,
> >> see if I can come up with something.
>
> >> Ryan Florence
>
> >> [Writing TextMate Snippets] (http://blog.flobro.com/)
>
> >> On Nov 8, 2009, at 3:28 PM, cbolson wrote:
>
> >>> Great little class Ryan, thanks for sharing it!
> >>> I am trying to adapt it slightly give it some "back" and "next"  
> >>> manual
> >>> controls.
> >>> The "next" I have achieved by simply calling the "looper" function,
> >>> however I am having trouble getting it to roll back.
> >>> Any suggestions as to how this could be done?
> >>> I tried adding a further method to the class like this but with no
> >>> luck:
> >>> unloop: function(){
> >>>    this.loopCount--;
> >>>    this.loopMethod(this.loopCount);
> >>>    return this;
> >>>    }
> >>> Thanks,
> >>> Chris
>
> >>> On 21 oct, 06:34, Ryan Florence <[email protected]> wrote:
> >>>> Makes sense to me.  Done.
>
> >>>> I actually made some posts about usingLoop(or any mixin, really):
>
> >>>>http://blog.flobro.com/#/posts/4-mootools-mixins-part-one-loop-
> >>>> jshttp...
> >>>> posts/5-mootools-mixins-part-two-
> >>>> spriteanimation-jshttp://blog.flobro.com/#/posts/6-mootools-mixins-
> >>>> part-three-
> >>>> simpleslideshow-js
>
> >>>> -Ryan Florence
>
> >>>> On Oct 20, 2009, at 9:07 PM, csuwldcat wrote:
>
> >>>>> What do you think about dropping the -ing on the start and stop
> >>>>> calls?  I say this only for length sake, take it or leave it :)
>
> >>>>> On Oct 19, 11:51 am, Rolf -nl <[email protected]> wrote:
> >>>>>> Not looping anything right now, but I like it anyway :)
> >>>>>> Also dig the wallpaper plugin, I think I can use it too which  
> >>>>>> saves
> >>>>>> me
> >>>>>> some time!
>
> >>>>>> Cheers
>
> >>>>>> On Oct 19, 8:22 pm, Ryan Florence <[email protected]> wrote:
>
> >>>>>>> Cool, thanks.
>
> >>>>>>> I plan on allowing users to have more than one library (at the
> >>>>>>> moment
> >>>>>>> you have to register twice for two libraries).  I'll also be
> >>>>>>> allowing
> >>>>>>> users to make libraries public or private, since some classes
> >>>>>>> are so
> >>>>>>> application specific you don't necessarily want to share them.
>
> >>>>>>> On Oct 19, 2009, at 11:53 AM, Eneko Alonso wrote:
>
> >>>>>>>> The site looks good too... I signed up and soon will be sharing
> >>>>>>>> some
> >>>>>>>> mootools snippets I have.
>
> >>>>>>>> On Sun, Oct 18, 2009 at 8:49 PM, Ryan Florence
> >>>>>>>> <[email protected]> wrote:
> >>>>>>>>> Thanks Fabio,
> >>>>>>>>> Here's probably a better demo of is use:
> >>>>>>>>>http://ryanflorence.com/scripts/mootools/InfiniteTicker/test/
> >>>>>>>>> On Oct 18, 2009, at 4:21 PM, Fábio M. Costa wrote:
>
> >>>>>>>>> oh nice, i always wanted to implement a mixin class but i just
> >>>>>>>>> cant
> >>>>>>>>> find a
> >>>>>>>>> generic case where it fits.
> >>>>>>>>> Nice one!
> >>>>>>>>> i see you got a lot of work in there Ryan.
> >>>>>>>>> Thanks for your contributions!
> >>>>>>>>> cya
>
> >>>>>>>>> --
> >>>>>>>>> Fábio Miranda Costa
> >>>>>>>>> Solucione Sistemas
> >>>>>>>>> Engenheiro de interface
>
> >>>>>>>>> On Sun, Oct 18, 2009 at 6:38 PM, Ryan Florence
> >>>>>>>>> <[email protected]> wrote:
>
> >>>>>>>>>>http://moodocs.ryanflorence.com/RpFlo/Loop
>
> >>>>>>>>>> It seems several of my classes end up with some methods to
> >>>>>>>>>> start,
> >>>>>>>>>> stop,
> >>>>>>>>>> and reset aloopthat's firing a function on a timer: image
> >>>>>>>>>> galleries, news
> >>>>>>>>>> tickers, twitter feeds, sprite animations, to name a few.
>
> >>>>>>>>>> Instead of writing out those methods every time, now I can  
> >>>>>>>>>> just
> >>>>>>>>>> implement
> >>>>>>>>>> Loopand I'm done.
>
> >>>>>>>>>> You can use it just like Options or Events in any class.
>
> >>>>>>>>>> Enjoy!

Reply via email to