﻿(function ($) { $.fn.vScroll = function (options) { var defaults = { speed: 500, upID: "#up-arrow", downID: "#bottom-arrow" }; var options = $.extend(defaults, options); return this.each(function () { obj = $(this); obj.parent().css("overflow", "hidden"); obj.parent().css("position", "relative"); obj.children().each(function (intIndex) { $(this).addClass("vscroll-" + intIndex); }); var itemCount = 0; $(options.downID).click(function () { var nextCount = itemCount + 1; if ($('.vscroll-' + nextCount).length) { var divH = $('.vscroll-' + itemCount).height(); itemCount++; $("#" + obj.attr('id')).animate({ top: "-=" + divH + "px" }, options.speed); } }); $(options.upID).click(function () { var prevCount = itemCount - 1; if ($('.vscroll-' + prevCount).length) { itemCount--; var divH = $('.vscroll-' + itemCount).height(); $("#" + obj.attr('id')).animate({ top: "+=" + divH + "px" }, options.speed); } }); }); }; })(jQuery);
