jQuery focus figure effect.
javascript
02 | var sWidth = $( "#focus" ).width(); |
03 | var len = $( "#focus ul li" ).length; |
07 | var btn = "<div class='btnBg'></div><div class='btn'>" ; |
08 | for ( var i=0; i < len; i++) { |
09 | btn += "<span>" + (i+1) + "</span>" ; |
12 | $( "#focus" ).append(btn); |
13 | $( "#focus .btnBg" ).css( "opacity" ,0.5); |
16 | $( "#focus .btn span" ).mouseenter( function () { |
17 | index = $( "#focus .btn span" ).index( this ); |
19 | }).eq(0).trigger( "mouseenter" ); |
21 | $( "#focus ul" ).css( "width" ,sWidth * (len + 1)); |
23 | $( "#focus ul li div" ).hover( function () { |
24 | $( this ).siblings().css( "opacity" ,0.7); |
26 | $( "#focus ul li div" ).css( "opacity" ,1); |
29 | $( "#focus" ).hover( function () { |
30 | clearInterval(picTimer); |
32 | picTimer = setInterval( function () { |
41 | }).trigger( "mouseleave" ); |
43 | function showPics(index) { |
44 | var nowLeft = -index*sWidth; |
45 | $( "#focus ul" ).stop( true , false ).animate({ "left" :nowLeft},500); |
46 | $( "#focus .btn span" ).removeClass( "on" ).eq(index).addClass( "on" ) |
49 | function showFirPic() { |
50 | $( "#focus ul" ).append($( "#focus ul li:first" ).clone()); |
51 | var nowLeft = -len*sWidth; |
52 | $( "#focus ul" ).stop( true , false ).animate({ "left" :nowLeft},500, function () { |
53 | $( "#focus ul" ).css( "left" , "0" ); |
54 | $( "#focus ul li:last" ).remove(); |
56 | $( "#focus .btn span" ).removeClass( "on" ).eq(0).addClass( "on" ); |
html
02 | < h1 >jQuery focus images</ h1 > |
07 | < div style = "left:0; top:0; width:560px; height:380px;" >< a href = "#" target = "_blank" >< img src = "img/a01.jpg" alt = "" /></ a ></ div > |
09 | < div style = "right:0; top:0; width:220px; height:140px;" >< a href = "#" target = "_blank" >< img src = "img/a02.jpg" alt = "" /></ a ></ div > |
10 | < div style = "right:0; top:140px; width:220px; height:140px;" >< a href = "#" target = "_blank" >< img src = "img/a03.jpg" alt = "" /></ a ></ div > |
11 | < div style = "right:0; bottom:0; width:220px; height:100px;" >< a href = "#" target = "_blank" >< img src = "img/a04.jpg" alt = "" /></ a ></ div > |
15 | < div style = "left:0; top:0; width:780px; height:380px;" >< a href = "#" target = "_blank" >< img src = "img/b01.jpg" alt = "" /></ a ></ div > |
19 | < div style = "left:0; top:0; width:260px; height:210px;" >< a href = "#" target = "_blank" >< img src = "img/c01.jpg" alt = "" /></ a ></ div > |
21 | < div style = "left:260px; top:0; width:260px; height:210px;" >< a href = "#" target = "_blank" >< img src = "img/c02.jpg" alt = "" /></ a ></ div > |
22 | < div style = "left:0; top:210px; width:520px; height:170px;" >< a href = "#" target = "_blank" >< img src = "img/c03.jpg" alt = "" /></ a ></ div > |
23 | < div style = "right:0; top:0; width:260px; height:380px;" >< a href = "#" target = "_blank" >< img src = "img/c04.jpg" alt = "" /></ a ></ div > |
27 | < div style = "left:0; top:0; width:560px; height:380px;" >< a href = "#" target = "_blank" >< img src = "img/d01.jpg" alt = "" /></ a ></ div > |
28 | < div style = "right:0; top:0; width:220px; height:140px;" >< a href = "#" target = "_blank" >< img src = "img/d02.jpg" alt = "" /></ a ></ div > |
29 | < div style = "right:0; top:140px; width:220px; height:140px;" >< a href = "#" target = "_blank" >< img src = "img/d03.jpg" alt = "" /></ a ></ div > |
30 | < div style = "right:0; bottom:0; width:220px; height:100px;" >< a href = "#" target = "_blank" >< img src = "img/d04.jpg" alt = "" /></ a ></ div > |
35 | < div style = "left:0; top:0; width:780px; height:380px;" >< a href = "#" target = "_blank" >< img src = "img/e01.jpg" alt = "" /></ a ></ div > |