-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
148 lines (118 loc) · 4.16 KB
/
main.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
137
138
139
140
141
142
143
144
145
146
147
148
// images 'class'
var images = new function(){
this.curr = 0;
/*this.list=[
"images/pharos.jpg",
"images/limani.jpg",
"images/faros.jpg",
"images/paliaPol.jpg",
"images/steno.jpg",
"images/trimart.jpg",
"images/gata.jpg"
];
*/
this.list=[
"pharos.jpg",
"limani.jpg",
"faros.jpg",
"paliaPol.jpg"
];
this.direct = "right";
}
window.onload = function() {
console.log("loaded");
/* menu stuff
// this is the function for the burger btn animation
var btn = document.getElementById("burger-btn");
var menu = document.getElementsByClassName('menu-wrapper')[0];
function changeBtn(event) {
//this.classList.toggle("change move-left");
this.classList.toggle("move-left");
//console.log(event);
}
function toggleMenu() {
menu.classList.toggle("resp-view");
}
btn.addEventListener("click", changeBtn);
btn.addEventListener("click", toggleMenu);
// end menu stuff */
var leftImg = document.getElementById("second-header-cont");
var rightImg = document.getElementById("header-cont");
var firstTxtCont = document.getElementById("first-curved-text");
var secondTxtCont = document.getElementById("second-curved-text");
var firstTxt = document.getElementById("first-div-text");
var secondTxt = document.getElementById("second-div-text");
var thirdTxt = document.getElementById("third-div-text");
var fourthTxt = document.getElementById("fourth-div-text");
var textInt = 0;
firstTxtCont.innerHTML = firstTxt.innerHTML;
function swipeText(){
// changing text function
if(textInt==3){
textInt=0;
}else {
textInt++;
}
if (textInt==0) {
firstTxtCont.innerHTML = firstTxt.innerHTML;
}else if (textInt==1) {
secondTxtCont.innerHTML = secondTxt.innerHTML;
}else if (textInt==2){
firstTxtCont.innerHTML = thirdTxt.innerHTML;
}else if (textInt==3) {
secondTxtCont.innerHTML = fourthTxt.innerHTML;
}
}
function swipe(){
// preload hack
if (images.curr==images.list.length){
rightImg.style = "right:0%;"+"background-image: url('" + String(images.list[0]) + "');";
leftImg.style = "right:0%;"+"background-image: url('" + String(images.list[0]) + "');";
}else {
rightImg.style = "right:0%;"+"background-image: url('" + String(images.list[images.curr]) + "');";
leftImg.style = "right:0%;"+"background-image: url('" + String(images.list[images.curr]) + "');";
}
// code to init the swipe effect
if (images.direct==="right") {
rightImg.style = "right:-100%;"+"background-image: url('" + String(images.list[images.curr]) + "');";
if(images.curr==images.list.length-1){
leftImg.style = "left: 0%;"+"background-image: url('" + String(images.list[0]) + "');";
}else{
leftImg.style = "left: 0%;"+"background-image: url('" + String(images.list[images.curr+1]) + "');";
}
images.direct = "left";
}else if (images.direct==="left") {
leftImg.style = "left: -100%;"+"background-image: url('" + String(images.list[images.curr]) + "');";
if (images.curr==images.list.length-1){
rightImg.style = "right:0%;"+"background-image: url('" + String(images.list[0]) + "');";
}else{
rightImg.style = "right:0%;"+"background-image: url('" + String(images.list[images.curr+1]) + "');";
}
images.direct = "right";
}
images.curr += 1;
if (images.curr==images.list.length){
images.curr = 0;
}
}
setInterval(swipeText, 4000);
setInterval(swipe, 4000);
// this is the function for the burger btn animation
var btn = document.getElementById("burger-btn");
//var menu = document.getElementsByClassName('menu-wrapper')[0];
var mainMenu = document.getElementById('main-nav-id');
/*btn.addEventListener("click", function(){
this.classList.toggle("change");
});*/
function changeBtn(event) {
this.classList.toggle("change");
this.classList.toggle("move-left");
//console.log(event);
}
function toggleMenu() {
//menu.classList.toggle("resp-view");
mainMenu.classList.toggle("resp-view");
}
btn.addEventListener("click", changeBtn);
btn.addEventListener("click", toggleMenu);
}