-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathblog.js
More file actions
69 lines (65 loc) · 1.98 KB
/
blog.js
File metadata and controls
69 lines (65 loc) · 1.98 KB
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
var slideIndex,slides,nSlide,dott,flag=0;
slideIndex=0;
function initGallery()
{
slides=document.getElementsByClassName("imageHolder");
slides[slideIndex].style.opacity=1;
dott=[];
var dotsContainer= document.getElementById("dotsContainer");
for(var i=0;i<slides.length;i++)
{
var dot=document.createElement("span");
dot.classList.add("dots");
dotsContainer.append(dot);
dott.push(dot);
}
dott[slideIndex].classList.add("active");
}
setTimeout(function () {
move(1);
}, 5000);
function move(side)
{
if(flag==0)
{
// side = 0 (left)
if (side == 0)
{
//next slide
if (slideIndex == 0)
nSlide = slides.length - 1;
else
nSlide = slideIndex - 1;
}
else //side=1 (right)
{
if (slideIndex == slides.length-1)
nSlide = 0;
else
nSlide = slideIndex + 1;
}
}
slides[slideIndex].style.opacity=0;
dott[slideIndex].classList.remove("active");
slides[nSlide].style.opacity=1;
dott[nSlide].classList.add("active");
slideIndex = nSlide;
flag=0;
/*setTimeout(function () {
move(1);
}, 3000);*/
}
initGallery();
for (var i = 0; i<dott.length; i++)
{
circle(i);
}
function circle(i)
{
dott[i].onclick = function() {
nSlide=i;
console.log(nSlide);
flag=1;
move(0);
};
}