(function($){
$.fn.ddCarousel = function(options){
var defaults = {
//btnPrev: null, // previous button customization
//btnNext: null, // next button customization
//mouseWheel: true, // shall the carousel handle the mousewheel event to animate ?
auto: false, // shall the carousel start automatically
speed: 2000, // speed in ms of the animation.
easing: 'linear', // linear animation.
direction : 'left',
circular: true, // run in circular mode. Means : images never reach the end.
visible: '50%', // size of the carousel on the screen. Can be in percent '100%', in pixels '100px', or in images '3' (for 3 images)
//vertical: false, // set the carousel in a vertical mode
//start: 0, // position in pixels that the carousel shall start at
//scroll: 1,
//step: 50, // value in pixels, or "default"
//eltByElt: false, // if activated, the carousel will move image by image, not more, not less.
//evtStart : 'mouseover', // start event that we want for the animation (click, mouseover, mousedown, etc..)
//evtStop : 'mouseout', // stop event that we want for the animation (blur, mouseout, mouseup, etc..)
//beforeStart: null, // Not used yet
//afterEnd: null // Not used yet
};
var opts = $.extend(defaults, options);
//console.log(opts.position);
return this.each(function(){
var div = $(this); // selecting div
var ul = $(this).children('ul'); //selecting ul
var li = ul.children('li')
var tChild = $(ul).children('li').size(); //getting length of childs
var tChildWidth = $(ul).children('li').outerWidth(true); //getting width of a single child
var vis = opts.visible;
var lastInCss = (vis.toString().indexOf("%") != -1 ? '%' : (vis.toString().indexOf("px") != -1) ? 'px' : 'el');
ul.css("width", tChildWidth*tChild + 'px');
var cWid = ul.outerWidth()
// Calculates the size of the main div according to the given size (can be in...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.