首頁 > web前端 > js教程 > Javascript Web Slider 焦點圖範例原始碼_javascript技巧

Javascript Web Slider 焦點圖範例原始碼_javascript技巧

WBOY
發布: 2016-05-16 17:20:32
原創
1104 人瀏覽過

HTML程式碼:

複製程式碼程式碼如下:

;


;

標題>

*{padding:0;margin:0}
ul{list-style:none}
.slider-focus{width:670px;height:240px;overflow:hidden;position:relative;margin: 100px 自動}
.slider-focus .slider{width:3500px;位置:絕對;左:slider-focus .slider{width:3500px;位置:絕對;左:0px;上圖:0px;高度:240px}
.slider-focus .slider li{float:left;}
.slider-focus .btns{位置:絕對;右:0px;底部:5px}
. slider-focus .btns li{寬度:18px;高度:18px;浮動:左;背景:#fff;右邊距:5px;遊標:指針}
.slider-focus .btns li.cur{背景:#f60 }
;
頭>



    Javascript Web Slider 焦點圖範例原始碼_javascript技巧">">
  • Javascript Web Slider 焦點圖範例原始碼_javascript技巧

  • Javascript Web Slider 焦點圖範例原始碼_javascript技巧

  • Javascript Web Slider 焦點圖範例原始碼_javascript技巧









身體>


JavaScript 程式碼: 程式碼如下:


function Sliderfocus(options){ this.slider = options.slider;
this.btns = options.btns;
this.width = options.width;
this.speed = options.speed =peed | | 800;
this.curIndex = options.curIndex || 0;
this.size = this.btns.size();
this.init();
this.timeout = null;
this.init();
this.timeout = null;
this.stopTemp = 1 ;
}

Sliderfocus.prototype = {
init:function(){
this.auto();
this.bind() ;
},
play:function(){
this.slider.stop().animate({
left:-this.curIndex * this.width
},this.speed ) ;
},
auto:function(){
var that = this;
this.timeout = setTimeout(function(){
if(that.stopTemp == 0){
return;
}else{
that.next();
that .auto();
}
},4000);
},
prev :function(){
this.curIndex = --this.curIndexthis.play();
},
next:function (){
this.curIndex = this.curIndex>this.size-1? 0 : this.curIndex;
console.log(this.curIndex)
this.play();
} ,
stop:function(){
this.stopTemp = 0;
},
bind:function(){
var that = this;
this.focus.bind( "mouseover",function(){
that.stop();
}).bind("mouseout",function(){
that.stopTemp = 1 ;
//that.auto ();
});
this.letsgo();
},
letsgo:function(){
var that = this;
this.btns.bind(" click",function(){
var index = $(this).index();
that.curIndex = index;
that.play();

});
}
};

new Sliderfocus({
焦點:$(".slider-focus"),
slider:$(".slider-focus .slider"),
btns:$(" .btns li"),
寬度:670
});
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板