JQuery. slide1.3x

Source: Internet
Author: User

JQuery. slide1.3x
$. Fn. extend ({
// Common usage: move the mouse over | click to switch the image,
// Call method, $ ("object"). changeImg ("Event ")
ChangeImg: function (event)
{
Var index = 0;
$ (This). eq (index). find ("img"). eq (0). hide ();
$ (This). bind (event, function ()
{
Index = $ (this). index (this );
$ (This). eq (index). find ("img"). eq (0). hide ();
$ (This). eq (index). siblings (this). find ("img"). show ();
});
Return this;
},
// Common usage: The mouse goes by | switches the class when you click it. The default switching class here is on.
// Call method: $ ("object"). tabClassName ("Event ")
TabClassName: function (event)
{
Var index = 0;
$ (This). bind (event, function ()
{
Index = $ (this). index (this );
$ (This). eq (index). addClass ("on"). siblings (this). removeClass ("on ");
});
Return this;
},
// Frequently used: Click | switch the content under the menu
// Call method $ ("event Target"). changeCnt ("content target", "Event ");
ChangeCnt: function (cnt, event)
{
Var index = 0;
$ (Cnt). eq (0). show ();
$ (This). bind (event, function ()
{
Index = $ (this). index ();
$ (Cnt). eq (index). show (). siblings (cnt). hide ();
});
Return this;
},
// Common usage: When the cursor passes through a certain area, the lower part of the current div slides up
// Call method: $ ("event Target"). changeCnt ("current target subordinate", "original subordinate top ");
// If Initialization is required, you can add on to the first element in html. The default class here is on.
InnerScroll: function (insertBox, top)
{
$ (This). hover (function ()
{
$ (This). find (insertBox). stop (true, false). animate ({top: 0}, 200 );
$ (This). addClass ("on ");
}, Function ()
{
$ (This). find (insertBox). stop (true, false). animate ({top: top}, 200 );
$ (This). removeClass ("on ");
});
Return this;
},
// Fixed top menu
FixedMen: function (hd)
{
Var _ this = $ (this );
$ (Window). scroll (function ()
{
Var hh = $ (hd). outerHeight ();
If ($ (window). scrollTop ()> hh)
{
_ This. addClass ("fixedMenu ");
} Else
{
_ This. removeClass ("fixedMenu ");
}
});
Return _ this;
},


// Click to scroll to the specified region
FixedMenScroll: function (offTop)
{
$ (This). click (function ()
{
Var index = $ (this). index () + 1;
Var To = $ ("# MenScroll" + index). offset (). top-offTop + "px ";
$ ("Body, html"). animate ({scrollTop: To}, 500 );
});
Return this;
},
// Return to the top
ToTop: function (height)
{
Var _ this = this;
_ This. click (function ()
{
$ ('Body, html '). animate ({scrollTop: 0}, 300 );
Return false;
});
If (height)
{
WinTH ();
$ (Window). scroll (function ()
{
WinTH ();
});
Function winTH ()
{
$ (Window). scroll (function ()
{
If ($ (window). scrollTop ()> height)
{
_ This. fadeIn ();
}
Else
{
_ This. fadeOut ();
}
});
}
}


},
ImgLoop: function (speed, th, bd) // seamless scrolling
{
Var oBox =$ (this );
Var oUl = oBox. children (bd );
Var aUlLi = oUl. children ("li ");
Var btn = null;
Var btnLi = null;
Var Prev = oBox. children (". prev ");
Var Next = oBox. children (". next ");
Var oneWidth = aUlLi. outerWidth ();
Var iNow = 0; // Control List
Var iNow2 = 0; // small image control
If (oBox. children (th). find ("ul") {// if. hd is found, a small icon is generated.
Btn = oBox. children (th). find ("ul ");
For (var I = 0; I {
$ ("

  • "+ ParseInt (I + 1) +"
  • "). AppendTo (btn );
    }
    BtnLi = btn. children ("li ");
    Btn. width (btnLi. length + 1) * btnLi. width ());
    TagName (iNow2 );
    BtnLi. mouseover (function (){
    INow = iNow2 = $ (this). index ();
    TagName (iNow2 );
    Move (iNow );
    });
    }
    OUl. width (oneWidth * aUlLi. length );
    Prev. click (function (){
    If (! OUl. is (": animated "))
    {
    If (iNow> = aUlLi. length)
    {
    INow = 0;
    AUlLi.eq(0).css ({"position": "status", "left": 0 });
    OUl.css ({"left": 0 });
    }
    If (iNow> = aUlLi. length-1) // critical point
    {
    AUlLi.eq(0).css ({"position": "relative", "left": aUlLi. length * oneWidth });


    }
    INow ++;
    If (iNow> 1) // restore the disguise of the last element in the list
    {
    AUlLi.eq(aUlLi.length-1).css ({"position": "static", "left": 0 });
    }
    If (oBox. children (". hd"). find ("ul"). length) // if. hd exists, perform the switchover.
    {
    INow2 ++;
    If (iNow2> aUlLi. length-1 ){
    INow2 = 0;
    }
    TagName (iNow2 );
    }
    Move ();
    }
    });
    Next. click (function ()
    {


    If (! OUl. is (": animated") // determines whether the animation is in motion.
    {


    If (iNow <=-1)
    {
    INow = aUlLi. length-1;
    AUlLi.eq(aUlLi.length-1).css ({"position": "static", "left": 0 });
    OUl.css ({"left":-(aUlLi. length-1) * aUlLi. eq (0). outerWidth ()})
    }
    If (iNow <= 0) // critical point
    {
    AUlLi.eq(aUlLi.length-1).css ({"position": "relative", "left":-(aUlLi. length) * aUlLi. outerWidth ()})
    }
    INow --;


    Console. log (iNow );
    If (iNow {
    AUlLi.eq(0).css ({"position": "status", "left": 0 });
    }
    If (oBox. children (". hd"). find ("ul"). length) // if. hd exists, perform the switchover.
    {
    INow2 --;
    If (iNow2 <0)
    {
    INow2 = aUlLi. length-1;
    }
    TagName (iNow2 );
    }
    Move ();
    }


    });
    Function move ()
    {
    OUl. stop (false, true). animate ({left:-oneWidth * iNow}, speed)
    }
    Function tagName (iNow2 ){
    BtnLi. eq (iNow2). addClass ("on"). siblings (btnLi). removeClass ("on ");
    }


    },
    Marquee: function (drt) // marquee, Marquee
    {
    Var _ this = this;
    Var wrap = _ this. find (". wrap ");
    Var box1 = wrap. find (". box1 ");
    Var box2 = wrap. find (". box2 ");
    Var Prev = _ this. find (". prev ");
    Var Next = _ this. find (". next ");
    If (Prev & Next)
    {
    Prev. click (function ()
    {
    If (wrap. position (). left <=-(parseInt (wrap. outerWidth ()/2)-158 ))
    {
    Wrap.css ("left", "0 ");
    }
    Else
    {
    Wrap. animate ({"left": wrap. position (). left-158}, 300 );
    }
    });
    Next. click (function ()
    {
    // Var iNow = wrap. position (). left;
    If (wrap. position (). left >=- 158)
    {
    Wrap.css ("left",-(parseInt (wrap. outerWidth ()/2 )));
    }
    Else
    {
    Wrap. animate ({"left": wrap. position (). left + 158}, 300 );
    }
    });
    }


    Box2.html(box1.html ());
    Var marquee = null;
    Switch (drt ){
    Case "right ":
    Case "left ":
    Marquee = function ()
    {
    Box1.width (box1.find ("li"). outerWidth (true) * box1.find ("li"). length );
    Box2.width (box1.width ());
    Wrap. width (box1.width () * 2 );
    Switch (drt)
    {
    Case "right ":
    If (wrap. position (). left> = 0)
    {
    Wrap.css ("left",-wrap. outerWidth ()/2 );
    }
    Else
    {
    Wrap.css ("left", parseInt (wrap. position (). left + = 1 ));
    }
    Break;
    Case "left ":
    If (wrap. position (). left <=-parseInt (wrap. width ()/2 ))
    {
    Wrap.css ("left", "0 ");
    }
    Else
    {
    Wrap.css ("left", wrap. position (). left-= 1 );
    }
    Break;
    }


    };
    Break;
    Case "top ":
    Case "bottom ":
    Marquee = function ()
    {
    Switch (drt ){
    Case "top ":
    If (wrap. position (). top <= parseInt (-wrap. height ()/2 )){
    Wrap.css ("top", "0 ");
    }
    Else {
    Wrap.css ("top", wrap. position (). top-= 1 );
    }
    Break;
    Case "bottom ":
    If (wrap. position (). top> 0 ){
    Wrap.css ("top", parseInt (-wrap. height ()/2 ));
    }
    Else {
    Wrap.css ("top", wrap. position (). top + = 1 );
    }
    Break;
    }
    };
    }
    _ This. timer = setInterval (marquee, 30 );
    _ This. mouseover (function () {clearInterval (_ this. timer )});
    _ This. mouseout (function () {_ this. timer = setInterval (marquee, 30 );})
    }
    });

    Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.