-
Notifications
You must be signed in to change notification settings - Fork 0
/
indexJ2.html
209 lines (177 loc) · 7.67 KB
/
indexJ2.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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- CUSTOM STYLESHEET -->
<link rel="stylesheet" href="styleC1.css">
<link rel="stylesheet" href="styleJ1.css">
<link rel="stylesheet" href="styleC2.css">
<link rel="shortcut icon" type="image/png" sizes="32x32" href="KraczyCarouselLogo.png">
<link rel="shortcut icon" type="image/png" sizes="96x96" href="KraczyCarouselLogo.png">
<link rel="shortcut icon" type="image/png" sizes="16x16" href="KraczyCarouselLogo.png">
<title>KrazyCarousel | JSCarousel2 </title>
<script>
alert("Carousel slides automatically in time interval of 5 seconds");
</script>
<style>
.captions {
margin-top: 0;
margin-top: -12%;
}
.captionHeading {
font-size: 22px;
text-align: center;
/* margin-top: -5%; */
}
.carousel-inner>.item {
text-align: center;
}
</style>
</head>
<body class="bodyArea">
<a href="index.html" class="logo">Krazy<span class="logoSpan">Carousel</span></a>
<!-- <div class="parentNav"> -->
<div class="parentContainer">
<h1 class="heroHeading">Captions on Image<a class="backBtn" href="indexDashboardJS.html">Go Back</a></h1>
<br>
<div class="carousel">
<!-- Image Here -->
<div class="carousel-inner">
<div class="carousel-control left" onclick="clickedLeft()">
<div class="arrow left"></div>
</div>
<div class="item active">
<div class="container">
<img src="pic1.jpg" alt="Image Alt 1">
<div class="captions">
<div class="captionHeading">Caption 1</div>
<div class="captionPara">
<p>The authors of this book have used their best efforts in preparing this book.</p>
</div>
</div>
</div>
</div>
<div class="item">
<div class="container">
<img src="pic2.jpg" alt="Image Alt 2">
<div class="captions">
<div class="captionHeading">Caption 2</div>
<div class="captionPara">
<p>The publisher of this book have used their best efforts in preparing this book.</p>
</div>
</div>
</div>
</div>
<div class="item">
<div class="container">
<img src="pic3.jpg" alt="Image Alt 3">
<div class="captions">
<div class="captionHeading">Caption 3</div>
<div class="captionPara">
<p>The authors of this book have used their best efforts in preparing this book.</p>
</div>
</div>
</div>
</div>
<div class="item">
<div class="container">
<img src="pic4.jpg" alt="Image Alt 3">
<div class="captions">
<div class="captionHeading">Caption 4</div>
<div class="captionPara">
<p>The authors of this book have used their best efforts in preparing this book.</p>
</div>
</div>
</div>
</div>
<div class="carousel-control right" onclick="clickedRight()">
<div class="arrow right"></div>
</div>
</div>
<!-- Carousel Controls -->
<ol class="carousel-indicators">
<li class="active" id="listItem1"></li>
<li class="pasve" id="listItem2"></li>
<li class="pasve" id="listItem3"></li>
<li class="pasve" id="listItem4"></li>
</ol>
</div>
<script>
var items = document.querySelectorAll('.carousel .item');
var dots = document.querySelectorAll('.carousel-indicators li');
var currentItem = 0;
var isEnabled = true;
function changeCurrentItem(n) {
currentItem = (n + items.length) % items.length;
}
function nextItem(n) {
hideItem('to-left');
changeCurrentItem(n + 1);
showItem('from-right');
}
function previousItem(n) {
hideItem('to-right');
changeCurrentItem(n - 1);
showItem('from-left');
}
function goToItem(n) {
if (n < currentItem) {
hideItem('to-right');
currentItem = n;
showItem('from-left');
} else {
hideItem('to-left');
currentItem = n;
showItem('from-right');
}
}
// #####################################################
function hideItem(direction) {
isEnabled = false;
items[currentItem].classList.add(direction);
dots[currentItem].classList.remove('active');
items[currentItem].addEventListener('animationend', function() {
this.classList.remove('active', direction);
});
}
function showItem(direction) {
items[currentItem].classList.add('next', direction);
dots[currentItem].classList.add('active');
items[currentItem].addEventListener('animationend', function() {
this.classList.remove('next', direction);
this.classList.add('active');
isEnabled = true;
});
}
// #################################################
document.querySelector('.carousel-control.left').addEventListener('click', function() {
if (isEnabled) {
function stopSetinterval() {
clearInterval(slideTimer);
}
previousItem(currentItem);
}
});
document.querySelector('.carousel-control.right').addEventListener('click', function() {
if (isEnabled) {
function stopSetinterval() {
clearInterval(slideTimer);
}
nextItem(currentItem);
}
});
document.querySelector('.carousel-indicators').addEventListener('click', function(e) {
var target = [].slice.call(e.target.parentNode.children).indexOf(e.target);
if (target !== currentItem && target < dots.length) {
goToItem(target);
}
});
var slideTimer = setInterval(clickedRight, 5000);
function clickedRight() {
nextItem(currentItem);
}
</script>
</body>
</html>