jquery imitation Baidu experience sliding switch browsing effect

Source: Internet
Author: User

jquery imitation Baidu experience sliding switch browsing effect

 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26-27--28 29---30 31--32 33 34 35 36 37 38-39 40 41 42 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 5, 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 11 9 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148-149 150 151 $ (function () {Wordstrong (); $ ("#content ul"). Width ("#content ul Li:first"). Width () *$ ("#content ul li"). length); $ ("# header. top_right. Vote "). Hover (function () {$ (this). Children (". Hover-tip "). CSS (" display "," blocks "); $ (this). Children (". Num"). CSS ("display", "none"); The function () {$ (this). Children (". Hover-tip"). CSS ("display", "none"); $ (this). Children (". Num"). CSS ("Display", " Block "); });     $ ("#content. Left, #content. Right"). Width ($ (document). Width ()-$ ("#content"). Width ())/4); $ ("#content. Left"). CSS (' left ',-$ ("#content. Left"). Width ()); $ ("#content. Right"). CSS (' Right ',-$ ("#content. Right '). width ());   var showid = 0; $ ("#content span.left"). Hover (function () {if (Checkfirst ()) return; $ (this). CSS ("cursor", "pointer"); $ (this). Sibling S (". SL"). Stop (). Animate ({opacity:0.5}); The function () {$ (this). Siblings (". SL"). Stop (). Animate ({opacity:0}); Click (function () {if (Checkfirst ()) return; Showid-; $ ("#content"). attr ("Showid", Showid); $ ("#footer Li"). Children (). Removeclass ("active"). End (). Children (). EQ (showid). addclass ("active"); Center (SHOWID); });   $ ("#content span.right"). Hover (function () {if (Checklast ()) return; $ (this). CSS ("cursor", "pointer"); $ (this). s Iblings (". SR"). Stop (). Animate ({opacity:0.5}); The function () {$ (this). Siblings (". SR"). Stop (). Animate ({opacity:0});}). Click (function () {if (Checklast ()) return; Showid + + $ ("#content"). attr ("Showid", Showid); $ ("#footer Li"). Children () . Removeclass ("active"). End (). Children (). EQ (showid). addclass ("active"); Center (SHOWID); });   function Checkfirst () {if ($ ("#content"). attr ("showid") = = 0) {$ ("#content span.left"). CSS ("cursor", "Default") ; return true; return false; }   function Checklast () {if ($ ("#content"). attr ("showid") = = $ ("#content ul Li"). Length-1) {$ ("#content Span.rig HT "). CSS (" cursor "," Default "); return true; return false;  /* Initial capital */function Wordstrong () {var lilist = $ ("#content ul Li"); for (var j = 0; J < LiLIst.length; J + +) {var plist = $ ("#content. Cont_" + (j+1) + ". Cont_word p"); for (var i = 0; i < plist.length i + +) {var p = plist . get (i); var Pcont = $ (P). HTML (); var s = $ ("<b>" + (i+1) + "</b>"); S.css ("Font-size", "24px"); $ (P). HTML ('); S.appendto (P); $ (P). Append (pcont.substring (1)); }}   Center (0);  //Relative to Li Center function Center (liindex) {var li = $ ("#content ul li"). CSS ("opacity", 0.3). EQ (liindex). CSS ("opacity", 1); $ ("#content ul"). Animate ({left: (-li.width () *liindex)}); }   var Footlen = $ ("#content ul li"). length; var foots = $ ("#footer ul"); for (var i = 1; i < footLen-1 i + +) {var Childa = $ ("<a>"). HTML (i); Childa.attr ("href", "#"); $ ("<li>"). A Ppend (Childa). InsertBefore (Foots.children ("[Step=last]")). attr ("step", I); } foots.children (': Last '). attr ("step", footLen-1); Foots.css ("Left", ($ (window). Width ()-foots.width ())/2); $ ("#footer li"). Click (function () {$ ("#footer ul Li"). Children (). Removeclass ("active"); $ (this). Children (). ADdclass ("active"); Center ($ (this). attr ("step")); });   function myaddevent (obj, E, fn) {if (obj.attachevent) {obj.attachevent (' on ' +e, FN);} else Obj.addeventlistener (E, FN, false); }   function OnMouseWheel (EV) {var ev = ev| | Event IE//wheeldelta down: Negative, roll up: Lower//alert (Oevent.wheeldelta); FF//detail: Roll down: positive, up: Negative//alert (oevent.detail) var bdown = true; if (ev.wheeldelta) {bdown = ev.wheeldelta<0;} else {Bdown = ev.detail>0;} if (!bdown) {if (Checkfirst ()) return; Showid--;} else {if (Checklast ()) retur n; Showid + +; $ ("#content"). attr ("Showid", Showid); $ ("#footer ul Li"). Children (). Removeclass ("active"). End ()-eq (showid). Children (). addclass ("active"); Center (SHOWID); if (Oevent.preventdefault) {Oevent.preventdefault ();} return false; }   myaddevent (window, ' MouseWheel ', onmousewheel); Myaddevent (window, ' Dommousescroll ', onmousewheel); });
Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.