Forums Carousel

autoscroll or time delayed auto scroll

Subscribe to autoscroll or time delayed auto scroll 14 post(s), 7 voice(s)

 
Avatar jamesdin 4 post(s)

Is it possible to automatically scroll photos in the carousel?
Is it possible to time delay scroll of photos in the carousel?

 
Avatar Seb Administrator 133 post(s)

1) Is it possible to automatically scroll photos in the carousel?
Not directly with Carousel’s options but you can create your own timer, it’s pretty easy

2) Is it possible to time delay scroll of photos in the carousel?
What do you mean?

 
Avatar jamesdin 4 post(s)

I mean is it possible to get photos scroll automatically every 3 seconds? can you give me some pointers or links to existing libraries that have timers built in? I’m a newbie. :-)

 
Avatar Seb Administrator 133 post(s)

look at this http://prototypejs.org/api/periodicalExecuter

if you add this

 new PeriodicalExecuter(function() {
   hCarousel.scrollTo(hCarousel.currentIndex() + 1);
 }, 3);

to test_carousel.html, it works fine.

 
Avatar jamesdin 4 post(s)

You, sir, are a freaking genius. Genius I say. Yes, you are! This is awesome. Thank you very much. :-)

 
Avatar Seb Administrator 133 post(s)

I recommand this great book http://www.pragprog.com/titles/cppsu.
I did not write it and do not get any money with :), I was just a reviewer of the author (a friend of mine). You will learn everything about prototype and script.aculo.us.

 
Avatar jamesdin 4 post(s)

I would get that book in a heartbeat if I knew java. You see, I’m a complete newbie. I mean, html-is-a-programming-language type of a newbie. Can you recommend a Java book to somebody like me (no CS background)?

 
Avatar Osiride 1 post

Hi,
I use the function that Seb wrote, is exact what I want, but now I need an extra mod:
Is possible to stop the autoScrolling when the mouse cursor is over the DIV (or UL) of the carousel? (and obiviously continue when the mouse cursor is out)...?

thanks

 
Avatar Seb Administrator 133 post(s)

just observe mouseenter/leave on carousel div to start/stop the periodcal executer

 
Avatar mocax 4 post(s)

Hi,

I also used a periodic executer for my carousel, thus I don’t need a next and previous button.

However when I set previous and next button to false in the options, there will be an error that says this.previousButton is null.

 
Avatar blacksmith_tb 1 post

James,

Javascript != Java

There are lots of good Javascript books out there. It’s been so long that I’m not sure I could recommend an intro, though I see O’Reilly are about to publish one that looks great

Of course, there are lots of online references

I did just pick up the Pragmatic Prototype and script.aculo.us book, and it’s good, though not as a general intro to Javascript.

 
Avatar Ocsinet 2 post(s)

Hello, Seb you said:

just observe mouseenter/leave on carousel div to start/stop the periodcal executer

but periodicalexecuter has only stop method and not start..how can I do this?
Thanks

 
Avatar Ocsinet 2 post(s)

Hi, I wrote the solution.
After hacking prototype class with periodicalexecuter restart: http://dev.rubyonrails.org/ticket/9370 and support for mouseenter and mouseleave: http://dev.rubyonrails.org/attachment/ticket/83… , I noticed that the browser had a big load and often crashed, so I wrote my own code, in this way:

var x = null;

function startscroll() {
   x = window.setInterval(function scroll() {
    hCarousel.scrollTo(hCarousel.currentIndex() + 1);
   },3000);
}
function stopscroll() {
   window.clearInterval(x);
}
function runTest() {
  hCarousel = new UI.Carousel("horizontal_carousel", {direction: "horizontal"});
  startscroll();
  $('horizontal_carousel').observe('mouseover', stopscroll);
  $('horizontal_carousel').observe('mouseout', startscroll);
}
Event.observe(window, "load", runTest);

This is lighter code. I hope it will be useful.

 
Avatar Jangla 26 post(s)

Anyone know if it’s possible to smooth scroll the carousel rather than having it scroll in stages?

Also, if the scroll could reverse itself when it reaches the end it would be superfantastic :)

Forums Carousel