diff --git a/jquery.scrollbox.js b/jquery.scrollbox.js index 5bdcfb1..38af0cf 100644 --- a/jquery.scrollbox.js +++ b/jquery.scrollbox.js @@ -22,7 +22,9 @@ $.fn.scrollbox = function(config) { autoPlay: true, onMouseOverPause: true, paused: false, - queue: null + queue: null, + listElement: 'ul', + listItemElement:'li' }; config = $.extend(defConfig, config); config.scrollOffset = config.direction === 'vertical' ? 'scrollTop' : 'scrollLeft'; @@ -46,7 +48,7 @@ $.fn.scrollbox = function(config) { container.bind('mouseover', function() { paused = true; }); container.bind('mouseout', function() { paused = false; }); } - containerUL = container.children('ul:first-child'); + containerUL = container.children(config.listElement + ':first-child'); scrollForward = function() { if (paused) { @@ -58,7 +60,7 @@ $.fn.scrollbox = function(config) { scrollDistance, theStep; - curLi = containerUL.children('li:first-child'); + curLi = containerUL.children(config.listItemElement + ':first-child'); scrollDistance = config.distance !== 'auto' ? config.distance : config.direction === 'vertical' ? curLi.outerHeight(true) : curLi.outerWidth(true); @@ -74,11 +76,11 @@ $.fn.scrollbox = function(config) { if (newScrollOffset >= scrollDistance) { for (i = 0; i < config.switchItems; i++) { - if (config.queue && config.queue.find('li').length > 0) { - containerUL.append(config.queue.find('li')[0]); - containerUL.children('li:first-child').remove(); + if (config.queue && config.queue.find(config.listItemElement).length > 0) { + containerUL.append(config.queue.find(config.listItemElement)[0]); + containerUL.children(config.listItemElement + ':first-child').remove(); } else { - containerUL.append(containerUL.children('li:first-child')); + containerUL.append(containerUL.children(config.listItemElement + ':first-child')); } } container[0][config.scrollOffset] = 0; @@ -105,12 +107,12 @@ $.fn.scrollbox = function(config) { // init if (container[0][config.scrollOffset] === 0) { - liLen = containerUL.children('li').length; + liLen = containerUL.children(config.listItemElement).length; for (i = 0; i < config.switchItems; i++) { - containerUL.children('li:last-child').insertBefore(containerUL.children('li:first-child')); + containerUL.children(config.listItemElement + ':last-child').insertBefore(containerUL.children(config.listItemElement+':first-child')); } - curLi = containerUL.children('li:first-child'); + curLi = containerUL.children(config.listItemElement + ':first-child'); scrollDistance = config.distance !== 'auto' ? config.distance : config.direction === 'vertical' ? curLi.height() : curLi.width(); @@ -175,4 +177,4 @@ $.fn.scrollbox = function(config) { }); }; -}(jQuery)); \ No newline at end of file +}(jQuery));