-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathslide.js
37 lines (34 loc) · 1.35 KB
/
slide.js
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
$(document).ready(function(){
var activeSlide = 0;
var slide = $('.slider-inner .item').eq(activeSlide);
var slidePosition = 0;
var sliderPosition = 0;
$('.slider-inner').scrollLeft(slidePosition.left);
$('.slider-indicators li').eq(activeSlide).addClass("active");
$('.slider-indicators li').mouseenter(function(){
activeSlide = $(this).index();
if ($(this).attr('class') !== "active"){
$('.slider-indicators li').removeClass("active");
$('.slider-indicators li').eq(activeSlide).addClass("active");
slide = $('.slider-inner .item').eq(activeSlide);
slidePosition = slide.position();
sliderPosition = $('.slider-inner').scrollLeft() + slidePosition.left;
$('.slider-inner').scrollLeft(sliderPosition);
}
});
$('.slider-control').click(function(){
$('.slider-indicators li').removeClass("active");
if ($(this).hasClass("left") & (activeSlide !== 0)){
activeSlide -= 1;
}
if ($(this).hasClass("right") & (activeSlide !== 4)){
activeSlide += 1;
}
$('.slider-indicators li').eq(activeSlide).addClass("active");
slide = $('.slider-inner .item').eq(activeSlide);
slidePosition = slide.position();
sliderPosition = $('.slider-inner').scrollLeft() + slidePosition.left;
$('.slider-inner').scrollLeft(sliderPosition);
return false;
});
});