custom-javascript.js
4.32 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
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
149
150
151
152
153
154
155
156
157
158
159
// Add your custom JS here.
jQuery( document ).ready(function($) {
AOS.init();
$('.wp-block-button__link').attr('tabindex', 0);
$('.cf7mls_btn').attr('tabindex', 0);
$('#Layer_1').appendTo('.n2-ss-slider-wrapper-inside');
$('#Layer_1').show();
$(document).on("click","#register-here",function() {
$('.wp-block-group.register').toggle();
$('.numbers-second .wp-block-column:first-child a.wp-block-button__link').toggleClass('rotated');
$([document.documentElement, document.body]).animate({
scrollTop: $(".wp-block-group.register").offset().top
}, 500);
});
$( "#register-here" ).on( "keydown", function(event) {
if(event.which == 13){
$('.wp-block-group.register').toggle();
$('.numbers-second .wp-block-column:first-child a.wp-block-button__link').toggleClass('rotated');
$([document.documentElement, document.body]).animate({
scrollTop: $(".wp-block-group.register").offset().top
}, 500);
}
});
$('.wpcf7-form-control-wrap').each(function( index ) {
$(this).parent().addClass($(this).attr('class').split(' ')[1]);
});
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '36' == event.detail.contactFormId ) {
console.log('wpcf7submit');
$('.fieldset-cf7mls-wrapper').remove();
$('.cf7mls_progress_bar').remove();
$('.thank-you').show();
}
}, false );
var boxes = document.querySelectorAll("g");
var box = getShuffledArr(boxes);
function getShuffledArr (arr){
return [...arr].map( (_, i, arrCopy) => {
var rand = i + ( Math.floor( Math.random() * (arrCopy.length - i) ) );
[arrCopy[rand], arrCopy[i]] = [arrCopy[i], arrCopy[rand]]
return arrCopy[i]
})
}
box.forEach((element,i) => {
setTimeout(
function(){
animateMe(element)
}
, i * 750);
});
function animateMe(box){
let tl = gsap.timeline();
tl.to(box, 1.5, {opacity:0.6})
.to(box, 1.5,{opacity:0.07})
}
function randomNumber(min, max) {
return Math.random() * (max - min) + min;
}
updateContainer()
function updateContainer() {
var maxHeight = 0;
$(".numbers-block").each(function(index){
delay = index * 200 + 300;
$(this).attr('data-aos-delay', delay);
if ($(this).height() > maxHeight) { maxHeight = $(this).height(); }
});
$(".numbers-block").height(maxHeight);
}
$(window).on('resize', function(){
updateContainer()
})
function animateValue(id, start, end, duration) {
var start= 0 ;
// here we retrieve the text of the 'target' element by its 'id',
// and convert the returned value into a number, using
// parseInt(); the first argument is the string to convert and
// the second is the numeric base of the number into which you
// want to convert the given numeric string:
var end = parseInt(document.getElementById(id).textContent, 10);
var duration = 500;
var range = end - start;
var current = start;
var increment = end > start? 1 : -1;
var stepTime = Math.abs(Math.floor(duration / range));
var obj = document.getElementById(id);
var timer = setInterval(function() {
current += increment;
obj.innerHTML = current;
if (current == end) {
clearInterval(timer);
}
}, stepTime);
}
$(window).on('load resize scroll', function() {
// elementInViewport($('#number16'), 'number16');
// elementInViewport($('#number17'), 'number17');
elementInViewport($('#find-number'), 'find-number');
});
function elementInViewport(element, id) {
if (inViewport(element) && !$(element).hasClass('done')) {
animateValue(id ,0,0,5000);
$(element).addClass('done')
}
}
function inViewport(element) {
if (typeof jQuery === "function" && element instanceof jQuery) {
element = element[0];
}
var elementBounds = element.getBoundingClientRect();
return (
elementBounds.top >= 0 &&
elementBounds.left >= 0 &&
elementBounds.bottom <= $(window).height() &&
elementBounds.right <= $(window).width()
);
}
});