-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
110 lines (95 loc) · 3.1 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
//responsive menu
var small_menu = document.querySelector('.toggle_menu')
var menu = document.querySelector('.menu')
small_menu.onclick = function(){
small_menu.classList.toggle('active');
menu.classList.toggle('responsive');
}
//slider
const options = document.querySelectorAll(".our_card")
console.log(options)
options.forEach(option => {
option.addEventListener('mouseover', function() {
document.querySelectorAll(".our_card").forEach(removeActive => {
removeActive.classList.remove("active")
})
option.classList.add("active")
})
})
//animation text JS
var TxtRotate = function(el, toRotate, period) {
this.toRotate = toRotate;
this.el = el;
this.loopNum = 0;
this.period = parseInt(period, 10) || 2000;
this.txt = '';
this.tick();
this.isDeleting = false;
};
TxtRotate.prototype.tick = function() {
var i = this.loopNum % this.toRotate.length;
var fullTxt = Array.from(this.toRotate[i]).slice(0, this.toRotate[i].length).join('');
if (this.isDeleting) {
let max = this.txt.length === fullTxt.length ? 4 : 1
this.txt = Array.from(fullTxt).slice(0, this.txt.length - max).join('')
} else {
this.txt = Array.from(fullTxt).slice(0, this.txt.length + 1).join('')
}
this.el.innerHTML = '<span class="wrap">'+this.txt+'</span>';
var that = this;
var delta = 300 - Math.random() * 100;
if (this.isDeleting) { delta /= 2; }
if (!this.isDeleting && this.txt.length === fullTxt.length) {
delta = this.period;
this.isDeleting = true;
} else if (this.isDeleting && this.txt === '') {
this.isDeleting = false;
this.loopNum++;
delta = 500;
}
setTimeout(function() {
that.tick();
}, delta);
};
window.onload = function() {
var elements = document.getElementsByClassName('txt-rotate');
for (var i=0; i<elements.length; i++) {
var toRotate = elements[i].getAttribute('data-rotate');
var period = elements[i].getAttribute('data-period');
if (toRotate) {
new TxtRotate(elements[i], JSON.parse(toRotate), period);
}
}
// INJECT CSS
var css = document.createElement("style");
css = "text/css";
css.innerHTML = ".txt-rotate > .wrap { border-right: 0.08em solid #666 }";
document.body.appendChild(css);
};
$(document).ready(function(){
$('.navbar .menu li a').click(function(){
// applying again smooth scroll on menu items click
$('html').css("scrollBehavior", "smooth");
});
// owl carousel script
$('.carousel').owlCarousel({
margin: 20,
loop: true,
autoplayTimeOut: 2000,
autoplayHoverPause: true,
responsive: {
0:{
items: 1,
nav: false
},
600:{
items: 2,
nav: false
},
1000:{
items: 3,
nav: false
}
}
});
});