Home > Web Front-end > JS Tutorial > Javascript Web Slider focus chart example source code_javascript skills

Javascript Web Slider focus chart example source code_javascript skills

WBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWBOYWB
Release: 2016-05-16 17:20:32
Original
1159 people have browsed it

HTML代码:

复制代码 代码如下:





























Javasscript 代码:
复制代码 代码如下:

function Sliderfocus(options){
this.focus = options.focus;
this.slider = options.slider;
this.btns = options.btns;
this.width = options.width;
this.speed = options.speed || 800;
this.curIndex = options.curIndex || 0;
this.size = this.btns.size();
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.curIndex<0? this.size-1 : this.curIndex;
this.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({
focus:$(".slider-focus"),
slider:$(".slider-focus .slider"),
btns:$(".btns li"),
width:670
});
Related labels:
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Issues
MUI Slider Component: Different Colored Thumbs
From 1970-01-01 08:00:00
0
0
0
Can slider tracking animation be disabled?
From 1970-01-01 08:00:00
0
0
0
Why doesn't my Jquery slider display correctly?
From 1970-01-01 08:00:00
0
0
0
How to make slider preview slow motion
From 1970-01-01 08:00:00
0
0
0
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template