-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemplate3.js
76 lines (67 loc) · 2.28 KB
/
template3.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
const boxes_fly_in = document.querySelector('.about-us-img');
window.addEventListener('scroll', box_fly_in);
function box_fly_in(){
const TriggerBottom1 = window.innerHeight / 5 * 4;
const boxTop = boxes_fly_in.getBoundingClientRect().top;
console.log("vi tri cua window1: "+TriggerBottom1);
console.log("vi tri cua item1: " + boxTop);
if (boxTop < TriggerBottom1) {
boxes_fly_in.classList.add('show_fly_in');
}
else
boxes_fly_in.classList.remove('show_fly_in');
}
const models_fly_in = document.querySelectorAll('.model-fly-in');
window.addEventListener('scroll', model_get_fly_in);
function model_get_fly_in() {
const TriggerBottom3 = window.innerHeight * 5 / 4;
console.log("chieudai cua window " + TriggerBottom3);
models_fly_in.forEach((modelitem) => {
const getitemtop = modelitem.getBoundingClientRect().top;
console.log("top cua item " + getitemtop);
if (getitemtop < TriggerBottom3) {
modelitem.classList.add('show_model_fly_in');
}
else
modelitem.classList.remove('show_model_fly_in');
});
}
const text_fly_in = document.querySelectorAll('.about-us-slider');
window.addEventListener('scroll', about_us_fly_in);
function about_us_fly_in() {
const TriggerBottom2 = window.innerHeight / 5 * 4;
text_fly_in.forEach((text_top) => {
const gettop = text_top.getBoundingClientRect().top;
if (gettop < TriggerBottom2) {
text_top.classList.add('show_text_fly_in');
}
else
text_top.classList.remove('show_text_fly_in');
});
}
let DisplayValues = document.querySelectorAll('.num');
let interval = 5000;
DisplayValues.forEach((DisplayValue) => {
let start = 0;
let end = parseInt(DisplayValue.getAttribute("data-val"));
let duration = 0;
if (end <= 2000)
{
interval = 8000;
duration = Math.floor(interval / end);
console.log(duration);
}
else if (end > 2000)
{
interval = 0;
duration = Math.floor(interval / end);
console.log(duration);
}
let counter = setInterval(function () {
start += 1;
DisplayValue.textContent = start;
if (start == end) {
clearInterval(counter);
}
}, duration);
});