-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
207 lines (167 loc) · 4.68 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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
import "./scss/style.scss";
import $ from "jquery";
import ScrollMagic from 'scrollmagic'
//import 'scrollmagic/scrollmagic/uncompressed/plugins/debug.addIndicators.js'
//import Foundation from "foundation-sites";
//import moment from 'moment';
// init controller
var controller = new ScrollMagic.Controller({
// loglevel: 3
});
// create a scene
$(document).ready(function() {
$("[data-anim]").each(function(index, el) {
$(el).addClass($(el).data('anim')+' mui-enter')
new ScrollMagic.Scene({
triggerHook: 0.85,
triggerElement: el
})
.setClassToggle(el, "mui-enter-active")
//.addIndicators({name: $(el).data('anim')})
.addTo(controller)
});
$("[data-count]").each(function(index, el) {
$(this).html('0');
new ScrollMagic.Scene({
triggerHook: 0.85,
triggerElement: el
})
.on('enter',function(el2){
if(!$(el).data('complete')) counter($(el));
})
//.addIndicators({name: $(el).data('anim')})
.addTo(controller)
});
$("[data-countdec]").each(function(index, el) {
$(this).html('0');
new ScrollMagic.Scene({
triggerHook: 0.85,
triggerElement: el
})
.on('enter',function(el2){
if(!$(el).data('complete')) counterDec($(el));
})
//.addIndicators({name: $(el).data('anim')})
.addTo(controller)
});
$('hr').not('.key_stats_hr').each(function(index, el) {
$(el).css('transform','scaleX(0.5)')
new ScrollMagic.Scene({
triggerHook: 0.85,
triggerElement: el,
duration: '25%'
})
.on('progress leave;',function(event){
$(el).css('transform','scaleX('+( event.progress / 2 + 0.5 )+')')
})
//.addIndicators({name: $(el).data('anim')})
.addTo(controller)
});
function counter($el){
$el.prop('Counter',$el.data('start')).animate({
Counter: $el.data('end')
}, {
duration: 1000,
easing: 'swing',
step: function (now) {
$el.text(Math.ceil(now).toLocaleString('en'));
},
complete: function(){
$el.attr('data-complete',true);
}
});
}
function counterDec($el){
$el.prop('Counter',$el.data('start')*10).animate({
Counter: $el.data('end')*10
}, {
duration: 1000,
easing: 'swing',
step: function (now) {
let int = Math.ceil(now)/10
$el.text(int.toLocaleString('en'));
},
complete: function(){
$el.attr('data-complete',true);
}
});
}
function getBlockHeight($el){
$el.each(function(index, el) {
$(this).attr('data-height',$(this).find('.toggle_height').outerHeight())
if($(this).hasClass('open')){
$(this).find('.toggle_text').css('height', $(this).data('height')+"px")
}else{
$(this).find('.toggle_text').css('height', '')
}
});
}
getBlockHeight($('.toggle_panel'))
$(".toggle_all").click(function(event) {
event.preventDefault();
//console.log($(this).parent().find('.toggle_height').innerHeight())
$(this).parent().toggleClass('open');
getBlockHeight($(this).parent())
});
$(".bargraph .bar").hover(function() {
$(".bargraph .stats").css('opacity','0')
$(this).prev().css('opacity','1')
$(".bargraph .bar").css('opacity','0.5')
$(this).css('opacity','1')
},function(){
$(".bargraph .bar").css('opacity','1')
});
/*
SVG stroke anim:
dash-array: 473px
946 total
20% solid - 94 + 473 = 567
80% opac - 379 + 473 = 852
12% opac - 56 + 473 = 586
88% solid - 360 + 473 = 833
31% solid - 165 + 473 = 620
69% opac - 308 + 473 = 799
24% opac - 113 + 473 = 586
76% solid - 360 + 473 = 833
35% solid - 165 + 473 = 638
65% opac - 308 + 473 = 781
lt color: A46D82
*/
/*
const slides = $("section.priority");
slides.each(function(index, el) {
//console.log(slides)
//$(el).append("<div class='trigger_"+index+"'></div>")
new ScrollMagic.Scene({
triggerElement: "#trigger_"+index,
triggerHook: 1,
//duration: '100',
//pushFollowers: false
})
.setPin(slides[index])
.addIndicators({name: slides[index].className}) // add indicators (requires plugin)
.addTo(controller);
})
// // init
// var controller = new ScrollMagic.Controller({
// globalSceneOptions: {
// triggerHook: 'onLeave'
// }
// });
// // get all slides
// var slides = document.querySelectorAll("section.priority");
// // create scene for every slide
// for (var i=1; i<slides.length-1; i++) {
// console.log(slides[i],slides[i-1]);
// new ScrollMagic.Scene({
// triggerElement: slides[i],
// triggerHook: 1,
// // duration: '100',
// // pushFollowers: false
// })
// .setPin(slides[i-1])
// .addIndicators({name: slides[i-1].className}) // add indicators (requires plugin)
// .addTo(controller);
// }
*/
});