/* ================================================= // // jquery fixed plugins 1.3.1 // author : // url: // data : 2012-03-30 // // 参数 : float --> 悬浮方向[left or right] // minstatue --> 最小状态,只有show_btn // skin --> 皮肤控制 // durationtime --> 完成时间 //事例 : $("#scrollsidebar2").fix({ float : 'right', //default.left or right minstatue : true, //default.false or true skin : 'green', //default.gray or yellow 、blue 、green 、orange 、white durationtime : 1000 // }); // // =================================================*/ ;(function($){ $.fn.fix = function(options){ var defaults = { float : 'left', minstatue : false, skin : 'gray', durationtime : 1000 } var options = $.extend(defaults, options); this.each(function(){ //获取对象 var thisbox = $(this), closebtn = thisbox.find('.close_btn' ), show_btn = thisbox.find('.show_btn' ), sidecontent = thisbox.find('.side_content'), sidelist = thisbox.find('.side_list') ; var defaulttop = thisbox.offset().top; //对象的默认top thisbox.css(options.float, 0); if(options.minstatue){ $(".show_btn").css("float", options.float); sidecontent.css('width', 0); show_btn.css('width', 25); } //皮肤控制 if(options.skin) thisbox.addclass('side_'+options.skin); //核心scroll事件 $(window).bind("scroll",function(){ var offsettop = defaulttop + $(window).scrolltop() + "px"; thisbox.animate({ top: offsettop }, { duration: options.durationtime, queue: false //此动画将不进入动画队列 }); }); //close事件 closebtn.bind("click",function(){ sidecontent.animate({width: '0px'},"fast"); show_btn.stop(true, true).delay(300).animate({ width: '25px'},"fast"); }); //show事件 show_btn.click(function() { $(this).animate({width: '0px'},"fast"); sidecontent.stop(true, true).delay(200).animate({ width: '154px'},"fast"); }); }); //end this.each }; })(jquery);