-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
123 lines (114 loc) · 3.86 KB
/
index.html
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
<html>
<head>
<title>Light Slider</title>
<link rel="stylesheet" type="text/css" href="style.css" />
<script src="//code.jquery.com/jquery-1.12.1.js"></script>
<script src="//code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
</head>
<body>
<div class="container">
<div class="slider">
<section class="slides-container">
<article id="slide-1" class="slide">
<div class="numbertext"><h3>1 / 4</h3></div>
<img src="images/image1.jpg">
<div class="text"><h3>Caption One</h3></div>
</article>
<article id="slide-2" class="slide">
<div class="numbertext"><h3>2 / 4</h3></div>
<img src="images/image2.jpg">
<div class="text"><h3>Caption Two</h3></div>
</article>
<article id="slide-3" class="slide">
<div class="numbertext"><h3>3 / 4</h3></div>
<img src="images/image3.jpg">
<div class="text"><h3>Caption Three</h3></div>
</article>
<article id="slide-4" class="slide">
<div class="numbertext"><h3>4 / 4</h3></div>
<img src="images/image4.jpg">
<div class="text"><h3>Caption Four</h3></div>
</article>
<a class="prev">❮</a>
<a class="next">❯</a>
</section>
<footer>
<span id="dot-1" class="dot"></span>
<span id="dot-2" class="dot"></span>
<span id="dot-3" class="dot"></span>
<span id="dot-4" class="dot"></span>
</footer>
</div>
</div>
<script>
// start slider
var sliderLen = 4;
var sliderIndex = 1;
var sliderTimer = 3; // seconds
var animationTime = 1000; // milliseconds
$(function(){
//$(".slides-container").css("height", $(".slide").height());
//$( window ).resize(function() {
// $(".slides-container").css("height", $(".slide").height());
//});
$(".slide").css("display", "none");
$( ".dot" ).removeClass( "active" );
$("#slide-1").css("display", "block");
$("#dot-1").addClass("active");
});
var dotHandler = function (){
clearInterval( animationSlider );
i = $(this).attr('id').split('-')[1];
if ( i < sliderIndex ){
sliderPrevious ( i );
} else if ( i > sliderIndex ) {
sliderNext ( i );
}
}
var prevHandler = function (){
clearInterval( animationSlider );
sliderPrevious(sliderIndex - 1);
}
var nextHandler = function (){
clearInterval( animationSlider );
sliderNext(sliderIndex + 1);
}
$(".dot").on("click", dotHandler);
$(".prev").on("click", prevHandler);
$(".next").on("click", nextHandler);
animationSlider = setInterval(function() {
sliderNext(sliderIndex + 1);
}, sliderTimer * 1000);
function sliderNext( n ){
if (n > sliderLen){
n = 1;
}
$( ".dot" ).removeClass( "active" );
$("#dot-" + n).addClass("active");
$(".dot, .prev, .next").unbind("click");
$( "#slide-" + sliderIndex ).hide("slide", { direction: "left" }, animationTime);
$( "#slide-" + n ).show("slide", { direction: "right" }, animationTime, function () {
sliderIndex = n;
$(".dot").bind("click", dotHandler);
$(".prev").on("click", prevHandler);
$(".next").on("click", nextHandler);
});
}
function sliderPrevious( n ) {
if (n < 1){
n = sliderLen;
}
$( ".dot" ).removeClass( "active" );
$("#dot-" + n).addClass("active");
$(".dot, .prev, .next").unbind("click");
$( "#slide-" + sliderIndex ).hide("slide", { direction: "right" }, animationTime);
$( "#slide-" + n ).show("slide", { direction: "left" }, animationTime, function () {
sliderIndex = n;
$(".dot").bind("click", dotHandler);
$(".prev").on("click", prevHandler);
$(".next").on("click", nextHandler);
});
}
</script>
</body>
</html>