Quantcast
Viewing all articles
Browse latest Browse all 28

Re: AutoPlay on YUI3 Carousel

Hey Anna,

Add following code piece right before [Y.on("contentready"...] statement

Code:
Y.Carousel.prototype.startAutoPlay = function() {
   var B = this;
   u = B.get("autoPlayInterval");
   setInterval (doScrollForward, u);
   function doScrollForward() {
      B.scrollForward();
   }
}


or your full code should be line this:
Code:
YUI({gallery: 'gallery-2011.03.23-22-20'}).use("gallery-carousel", "substitute", "gallery-carousel-anim",  function (Y) {
   //add startAutoPlay method to Carousel widget's prototype
   Y.Carousel.prototype.startAutoPlay = function() {
      var B = this;
      u = B.get("autoPlayInterval");
      setInterval (doScrollForward, u);
      function doScrollForward() {
         B.scrollForward();
      }
   }


 
   Y.on("contentready", function () {
      var carousel = new Y.Carousel({
         boundingBox: "#gallery-carousel",
         numVisible: 1,
         autoPlayInterval: 5000,
         isCircular: true,
         contentBox: "#gallery-carousel > ul"
      });

      carousel.plug(Y.CarouselAnimPlugin, { animation: { speed: 0.2, effect: Y.Easing.easeOut } });
      carousel.render();
      carousel.startAutoPlay();
   }, "#footer");
});


The function hasn't been implemented in the widget yet but it doesn't mean you can't add it!

I hope this helps.

Viewing all articles
Browse latest Browse all 28

Trending Articles