jQuery
jQuery cycle plugin as carousel
On 14, Jun 2009 | 27 Comments | In jQuery | By abcoder
The jQuery cycle plugin is really amazing! I love this plugin for its huge options for image/div slide show. Right now I’m working on a project which has 3 slideshow on one page. One is simple fade effect with text divs, another one is also fade effect with div + image + text and play/pause, next/back option. The third one is a simple carousel with continuous play mode.
I implemented the first two easily with cycle plugin. But I got stuck with the carousel one. The play and the next state is fine as I used the “scrollLeft” fx. The problem is when I click previous button the fx should be “scrollRight” and not “scrollLeft”. I thought it may need a little complex customized function to do this job of applying different transition effect on previous and next event. I had no clue for it. Even no help from google search! I do not like using a lot of plugins at a time. I know there is jCarousel / jCarousel lite plugin for this, but I still believe there must be a way for doing this with cycle.
It took several hours to find out the simple solution. It’s already inside the cycle plugin, but kinda hidden! I am using the “scrollHorz” fx effect and it is fixed now. WOW! again I discovered that “cycle” is really a marvelous plugin of jQuery.
Here is the example on the malsup site: http://www.malsup.com/jquery/cycle/scrollhv.html
This is the simple code I used:
$('#carousels').cycle({
prev: '#left-arrow',
next: '#right-arrow',
pause: 1,
fx: 'scrollHorz',
timeout: 6000
});
-
Thanks for posting this, as I was just wondering if cycle could be used for a carousel.
-
Thanks for pointing me to the right documentation. I had almost pounded my head through the wall trying to implement it with scrollLeft and scrollRight.
-
Were you able to have multiple thumbs in your cycle carousel? I only can cycle through one thumb at a time!
-
Thanks adnan! This is really close to what I need. My only question: lets say you have six thumbnails. You want three to be visible at first and three to be invisible. Can you have the next and previous buttons run through the thumbs one at a time. You’re solution runs through three at a time. Thanks!
-
Does your scrollHorz sometimes not work in IE 7?
-
I have a slideshow using only cycle with a scroll horz. I have six thumbs, three visible at first with prev and next arrows to see the other three. I also have an automatic transition through each thumb but when it gets to the fourth thumb, it doesn’t scroll. Is this possible? Thanks!
-
Hi jvella,
with cycle plugin u can use multiple images or whatever per slide — just like jcarousel…
u can wrap multiple images by a div or any block item… or u can use my tiny $.splitUp function… which is able to make dynamically slit Up long slides… into new smaller segments/slides…$.fn.splitUp=function(splitBy,wrapper){ $all= $(this).find('>*'); var fragment=Math.ceil($all.length/splitBy); for (i=0;i<fragment;i++) $all.slice(splitBy*i,splitBy*(i+1)).wrapAll(wrapper); return $(this); }//guess max 3 images per slide
u can use it something like…$('div#slides') .splitUp(4,'<li class=splitUp><ul>') .cycle({ fx: 'scrollHorz' });or guess you have log ul/li slides….. in that case… use
$('div#slides') .splitUp(4,'<div/>') .cycle({ fx: 'scrollVert', next: '#scroll #down', prev: '#scroll #up', //fit: true, speed: 2000, timeout: 0, cleartype: 1 });thanks
-
Thanks for sharing cycle plugin.
-
but we can’t use jquery cycle to display more than 1 images at the time
-
Marvelous point of view. I must inform about it my to friend! Best Regards Grafik komputerowy.
-
Thanks so much for pointing this out. I had been trying to make it work with scrollLeft/scrollRight too!
-
I’m additionally interested in affilate and search engine marketing.
-
I have been exploring for a little for any high-quality articles or weblog posts in this sort of house . Exploring in Yahoo I ultimately stumbled upon this website. Studying this info So i am satisfied to convey that I have an incredibly just right uncanny feeling I found out just what I needed. I most definitely will make sure to don’t fail to remember this web site and provides it a look a continuing.
-
Thanks for posting this – saved me some time.
-
Awesome, I struggled to find a solution to this.
-
Thank you! I had just spend an hour trying to develop my own functions to scrollLeft and Right based on index. oi vey!
-
Many hours I’ve been searching for information about it. Finally, I managed to get the answer – thank to your article. Thanks a lot and keep posting!
-
hello,
So, your carousel looks like it automatically transitions every SIX SECONDS…
OR
you can click a NEXT / PREVIOUS button…
RIGHT?
Thanks!
-
Thanks man you saved me hours!
-
Thanks. It’s helpful for me!
-
I’d have to check with you in this article. That may be not one thing I usually do! I enjoy reading a blog post which will make people think. Also, appreciate it for allowing me to comment!
Submit a Comment
© Copyright 2012 ABCoder |













Comments