I wrote an image Carousel in my blog last time. I felt that I only realized the function and had some scalability problems. after a long time of research and reference, the upgraded version of image Carousel was available. Functions and scalability are greatly improved, and the encapsulation is very good. You can directly call the function and pass parameters. To put it bluntly, go directly to the source code.
Inde.html
<! Doctype HTML public "-// W3C // dtd xhtml 1.0 transitional // en" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<HTML xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> upgraded image carousel </title>
<Meta name = "keywords" content = "">
<Meta name = "Description" content = "">
<Link type = "text/CSS" rel = "stylesheet" href = "CSS/style.css"/>
<SCRIPT type = "text/JavaScript" src = "../jquery/jquery-1.8.3.min.js"> </SCRIPT>
<Script language = "JavaScript" src = "scroll. js"> </SCRIPT>
<SCRIPT>
$ (Document). Ready (function (){
// Produce different parameters as needed
Featurelist (". f_list ", {" onclass ":" hover "," offclass ":" "," pause_on_act ":" click "," interval ": 5000," Speed ": 5 });
});
</SCRIPT>
</Head>
<Body>
<Div class = "showpage">
<Div class = "mainbody">
<Div class = "flashbox f_list">
<Div class = "focusnew_out flashlist">
<Div style = "display: block;" class = "f_out">
<SPAN class = "f_out_txt"> <a href = "" target = "_ blank" Title = "Interview with Xu Ke> interview with Xu Ke </a> </span>
<A target = "_ blank" href = ""> </a>
</Div>
<Div style = "display: none;" class = "f_out">
<SPAN class = "f_out_txt"> <a href = "" target = "_ blank" Title = "movie time series Titanic"> movie time series Titanic </A> </span>
<A target = "_ blank" href = ""> </a>
</Div>
<Div style = "display: none;" class = "f_out">
<SPAN class = "f_out_txt"> <a href = "" target = "_ blank" Title = "Hollywood Christmas file menu exposure"> Hollywood Christmas file menu exposure </a> </span>
<A target = "_ blank" href = ""> </a>
</Div>
<Div style = "display: none;" class = "f_out">
<SPAN class = "f_out_txt"> <a href = "" target = "_ blank" Title = "movie with a head-on"> movie with a head-on hero dream </a> </span>
<A target = "_ blank" href = ""> </a>
</Div>
<Div style = "display: none;" class = "f_out">
<SPAN class = "f_out_txt"> <a href = "" target = "_ blank" Title = "use a digital movie chat"> use a digital movie chat </a> </span>
<A target = "_ blank" href = ""> </a>
</Div>
</Div>
<Div class = "f_tabs">
<SPAN class = "f_tab hover"> 1 </span>
<SPAN class = "f_tab"> 2 </span>
<SPAN class = "f_tab"> 3 </span>
<SPAN class = "f_tab"> 4 </span>
<SPAN class = "f_tab"> 5 </span>
</Div>
</Div>
</Html>
Scroll. js
VaR featurelist = function (fobj, options ){
// Functions called by carousel
Function feature_slide (NR ){
If (typeof Nr = "undefined "){
Nr = visible_idx + 1;
Nr = nR> = total_items? 0: NR; // If nr is greater than 5, count again from the beginning
}
Tabs. removeclass (onclass ). addclass (offclass ). filter (": eq (" + nR + ")"). removeclass (offclass ). addclass (onclass); // The Last style to be removed and added. The old and new styles are currently removed.
Output. Stop (True, true). Filter (": visible"). Hide (); // immediately hide the currently displayed Image
Output. Filter (": eq (" + nR + ")"). fadein ("slow", function (){
Visible_idx = nR;
});
}
Fobj = (typeof (fobj) = 'string ')? $ (Fobj): fobj;
Fobj = $ (fobj). eq (0 );
If (! Fobj | fobj. Size () = 0) return;
// Polling Interval
VaR Options = options | {};
VaR visible_idx = options. startidx | 0;
VaR onclass = options. onclass | "current ";
VaR offclass = options. offclass | "";
VaR speed = options. Speed | 10000;
Options. pause_on_act = options. pause_on_act | "click ";
Options. interval = options. interval | 50000;
VaR tabs = fobj. Find (". f_tabs. f_tab ");
VaR output = fobj. Find (". f_out ");
VaR total_items = tabs. length;
// Initial settings
Output. Hide (). eq (visible_idx). fadein ("slow ");
Tabs. eq (visible_idx). addclass (onclass );
If (options. interval> 0 ){
VaR timer = setinterval (function (){
Feature_slide ();
}, Options. interval );
Output. mouseenter (function (){
Clearinterval (timer );
}). Mouseleave (function (){
Clearinterval (timer );
Timer = setinterval (function (){
Feature_slide ();
}, Options. interval );
});
If (options. pause_on_act = "Mouseover "){
Tabs. mouseenter (function (){
Clearinterval (timer );
VaR idx = tabs. Index ($ (this ));
Feature_slide (idx );
}). Mouseleave (function (){
Clearinterval (timer );
Timer = setinterval (function (){
Feature_slide ();
}, Options. interval );
});
} Else {
Tabs. Click (function (){
Clearinterval (timer );
VaR idx = tabs. Index ($ (this ));
Feature_slide (idx );
});
}
}
}
Style Sheet: style.css
Body {Line-Height: 20px; font-family: verdana, Geneva, "", Helvetica, sans-serif; font-size: 12px ;}
A {color: # 26211d; text-Decoration: none ;}
A: hover {text-Decoration: underline}
. Showpage {width: 778px; margin: 0 auto; text-align: center ;}
. Showpage. flashbox {width: 706px; Height: 398px; float: Left; position: relative ;}
. Flashbox. focusnew_out {width: 706px; Height: 398px; position: relative; Z-index: 2}
. Flashbox. focusnew_out. f_out_txt {Height: 50px; width: 536px; display: block; position: absolute; bottom: 0; left: 0; Background-color: #000000; opacity: 0.8; color: # d6d6d6; font-size: 20px; font-family: ""; line-Height: 50px; padding: 0 150px 0 20px; overflow: hidden}
. Flashbox. focusnew_out. f_out_txt A {color: # d6d6d6 ;}
. Flashbox. f_tabs {
Width: 140px;
Height: 35px;
Position: absolute;
Bottom: 15px;
Right: 0px;
Z-index: 100;
}
. Flashbox. f_tabs span {width: 23px; Height: 19px; Background-color: #474747; float: Left; margin-Right: 3px; text-align: center; color: # f0f0f0; margin-top: 15px; cursor: pointer}
. Flashbox. f_tabs span. Hover {Height: 19px; Background-color: # b51017; margin-top: 0; padding-top: 15px; cursor: pointer}
Please smile.
This article is from the "7439523" blog. For more information, contact the author!
Upgraded image carousel