(Function ($ ){ $. Fn. easysroll = function (options ){ Var parameter = { Direction: "left ", Numberr: "1 ", Delayseconds: "1000 ", Scrolling: "1000 ", Fadein: false, EnterStop: true }; Var ops = $. extend (parameter, options ); Var $ this = $ (this ); Var _ this = this; Var _ time = null; Var obj = _ this. find ("[type = 'box']"); Var items = obj. find ("li "); Var itemsleg = items. length; Var itemsW = items. outerWidth (true ); Var itemsH = items. outerHeight (true ); Var _ direction = ops. direction; Var _ numberr = ops. numberr; Var _ delays = ops. delays; Var _ scrolling = ops. scrolling; Var _ fadein = ops. fadein; Var _ enterStop = ops. enterStop; If (_ direction = "top" | _ direction = "bottom ") { Items.css ({"float": "none "}); Obj. width (itemsW * itemsleg ); If (_ direction = "bottom "){ Obj.css ("margin-top",-_ numberr * itemsH ); } } Else if (_ direction = "left" | _ direction = "right "){ Items.css ({"float": "left "}); Obj. width (itemsW * itemsleg ); If (_ direction = "right "){ Obj.css ("margin-left",-_ numberr * itemsW ); } } Else { Alert ("the rolling direction you configured is incorrect. Please reconfigure "); Return true; } Function scroll (){ If (_ direction = "left "){ Obj. animate ({"margin-left":-_ numberr * itemsW}, Number (_ delays), function (){ For (var I = 0; I <_ numberr; I ++ ){ Obj. find ("li"). eq (0). appendTo (obj ); } Obj.css ({"margin-left": 0 }) If (_ fadein ){ Obj. find ("li"). eq (0). animate ({"opacity": 0}, Number (_ delays )); Obj. find ("li" 2.16.eq(itemsleg-12.16.css ({"opacity": 1 }); } }); } Else if (_ direction = "right "){ Obj. animate ({"margin-left": 0}, Number (_ delays), function (){ For (var I = 0; I <_ numberr; I ++ ){ Obj. find ("li"). eq (itemsleg-1). prependTo (obj ); }; Obj.css ("margin-left",-_ numberr * itemsW ); If (_ fadein ){ Obj. find ("li"). eq (0). animate ({"opacity": 1}, Number (_ delays )); Obj. find ("li" 2.16.eq(itemsleg-12.16.css ({"opacity": 0 }); } }); } Else if (_ direction = "top "){ Obj. animate ({"margin-top":-_ numberr * itemsH}, Number (_ delays), function (){ For (var I = 0; I <_ numberr; I ++ ){ Obj. find ("li"). eq (0). appendTo (obj ); } Obj.css ({"margin-top": 0 }); If (_ fadein ){ Obj. find ("li"). eq (0). animate ({"opacity": 0}, Number (_ delays )); Obj. find ("li" 2.16.eq(itemsleg-12.16.css ({"opacity": 1 }); } }); } Else if (_ direction = "bottom "){ Obj. animate ({"margin-top": 0}, Number (_ delays), function (){ For (var I = 0; I <_ numberr; I ++ ){ Obj. find ("li"). eq (itemsleg-1). prependTo (obj ); } Obj.css ("margin-top",-_ numberr * itemsH ); If (_ fadein ){ Obj. find ("li"). eq (0). animate ({"opacity": 1}, Number (_ delays )); Obj. find ("li" 2.16.eq(itemsleg-12.16.css ({"opacity": 0 }); } }); } } $ This. hover (function (){ If (_ enterStop ){ ClearInterval (_ time ); } }, Function (){ _ Time = setInterval (scroll, _ scrolling ); }). Trigger ('mouseleave '); } }) (JQuery ); |