-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathindex.js
136 lines (122 loc) · 3.9 KB
/
index.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
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
window.addEventListener('scroll', function () {
var header = document.querySelector('nav');
var height = window.innerHeight;
var width = window.innerWidth;
header.classList.toggle('sticky', window.scrollY > 0.20 * height);
});
window.addEventListener('keydown', function (e) {
if (e.code == 'ArrowLeft') {
arrowClicked(-1);
} else if (e.code == 'ArrowRight') {
arrowClicked(+1);
}
});
msliderprops = [
{
color: '#419dce',
title: 'IEEE LEARNING SERIES',
desc: 'Resume and Profile Building',
},
{
color: '#8422f3',
title: 'KALPANA 2021',
desc: 'AN IEEE PESU EC CAMPUS, WIE CHAPTER EVENT',
},
{
color: '#ffffffc9',
title: 'IEEE LEARNING SERIES',
desc: 'Aspire to achieve financial freedom',
},
];
var val = 0;
var slideIndex = 1;
handleSlider(slideIndex);
function plusDivs(n) {
handleSlider((slideIndex += n));
}
function arrowClicked(n) {
clearInterval(slider);
slider = setInterval(function () {
plusDivs(+1);
}, 4000);
plusDivs(n);
}
function handleSlider(n) {
var i;
var x = 3; //No of Posters
//Web
if (n > x) {
slideIndex = 1;
}
if (n < 1) {
slideIndex = x;
}
var offset = -1 * 100 * (slideIndex - 1);
var dots = document.getElementsByClassName('pagination-dot');
for (let d of dots) {
d.classList.remove('active');
}
dots[slideIndex - 1].classList.add('active');
document.getElementsByClassName('slidercontainer')[0].style.left =
offset + '%';
var right = document.getElementsByClassName('right-section')[0];
var image = document.getElementsByClassName('right-bg-image');
if (slideIndex == 2) {
// right.style.background = 'yellow';
image[0].style.opacity = 0;
image[2].style.opacity = 0;
image[1].style.opacity = 1;
}
if (slideIndex == 1) {
// right.style.background = "#419DCE";
image[0].style.opacity = 1;
image[2].style.opacity = 0;
image[1].style.opacity = 0;
}
if (slideIndex == 3) {
image[0].style.opacity = 0;
image[2].style.opacity = 1;
image[1].style.opacity = 0;
// right.style.background = 'green';
}
//Mobile
var area = document.getElementsByClassName('m-pagination-progress-bar');
document.getElementsByClassName('mslidercontainer')[0].style.left =
offset + '%';
if (area) {
area[0].style.width = slideIndex * (100 / 3) + '%';
}
var logos = document.getElementsByClassName('card');
if (slideIndex == 1) {
setTransform(logos[slideIndex + 1], -100, -180);
setTransform(logos[slideIndex], 100, 180);
} else {
setTransform(logos[(slideIndex - 2) % 3], -100, -180);
setTransform(logos[slideIndex % 3], 100, 180);
}
setTransform(logos[(slideIndex - 1) % 3], 0, 0);
var btmhalf = document.getElementsByClassName('btmhalf');
var title = document.getElementsByClassName('title');
var desc = document.getElementsByClassName('desc');
var area = document.getElementsByClassName('m-pagination-progress-bar');
btmhalf[0].style.background = msliderprops[slideIndex - 1].color;
title[0].innerHTML = msliderprops[slideIndex - 1].title;
desc[0].innerHTML = msliderprops[slideIndex - 1].desc;
}
// Set the visibilty and transistion of icons
function setTransform(element, translate, rotate) {
var transfromString =
'translateX(' + translate + '%) rotateY(' + rotate + 'deg )';
element.style.transform = transfromString;
if (translate == -100) {
element.style.transform_orign = 'center right';
}
if (translate == 100) {
element.style.visibility = 'hidden';
element.style.transform_orign = 'center right';
}
if (translate == 0) element.style.visibility = 'visible';
}
var slider = setInterval(function () {
plusDivs(+1);
}, 4000);