latesNews

(function($){
    $.fn.latesNews = function(opts){
        var defaults = {
            "speed" : 1000,
            "delay":500,
            "direct":"up",
            "ns":1
        }
    var opts = $.extend(defaults, opts);
    this.each(function(){
        var that = $(this);
        var ltime;
            that.hover(function(){
                clearInterval(ltime);
            },function(){
                ltime = setInterval(function(){
                    var lheight = that.find("li").height();
                    switch (opts.direct){
                        case "up":
                            that.animate({"marginTop":"-" + lheight * opts.ns + "px","opacity":0.5},opts.delay,function(){that.css({"margin-top":0,"opacity":1}).find("li:first").appendTo(that)});//截取第一
                            break;
                        case "down":
                            that.animate({"marginTop": lheight * opts.ns + "px"},opts.delay,function(){that.css({"margin-top":0}).find("li:first").appendTo(that)});
                            break;
                    }
                },opts.speed);
            }).trigger("mouseleave");
    });
    }
})(jQuery);

posted @ 2013-12-27 10:31  a fine day  阅读(113)  评论(0)    收藏  举报