-
Notifications
You must be signed in to change notification settings - Fork 4
/
app.js
152 lines (116 loc) · 4.1 KB
/
app.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
var intro = (function() {
function hasWebGL() {
//return false;
try {
return !!window.WebGLRenderingContext && !!document.createElement('canvas').getContext('experimental-webgl');
} catch (e) {
return false;
}
}
/*INTRO */
window.scrollTo(0,0);
if(window.innerWidth < 1025)
window.isMobile = true;
if(!hasWebGL())
window.noWebgl = true;
var keyframeCount = 30;
var currKeyframe = 0;
var lines = document.querySelectorAll('.intro-ring');
var totalLength = lines[0].getTotalLength();
var timer = setInterval(function(){
if(currKeyframe == keyframeCount)
clearInterval(timer);
lines[1].style.strokeDasharray = lines[0].style.strokeDasharray = (currKeyframe++/keyframeCount*totalLength)+'px, ' + totalLength+ 'px';
}, 16)
setTimeout(function() {
lazyProcess();
}, 800);
})();
var lazyProcess = (function() {
var jsProgress = 0.0,
cssProgress = 0.0,
imgProgress = 0.0;
var cssList = [
'css/fonts.css',
'css/icomoon/style.css',
];
for(var key in _cssDirs){
cssList.push.apply(cssList, _cssDirs[key])
}
var jsList = [
'https://cdnjs.cloudflare.com/ajax/libs/sketch.js/1.0.0/sketch.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/d3/3.5.5/d3.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/three.js/r70/three.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/gsap/1.16.0/TweenMax.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/gsap/1.16.0/plugins/ScrollToPlugin.min.js',
'https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.8/ace.js',
'https://cdnjs.cloudflare.com/ajax/libs/ace/1.1.8/theme-github.js',
'https://cdnjs.cloudflare.com/ajax/libs/slabText/2.3/jquery.slabtext.min.js'
]
for(var key in _jsDirs){
jsList.push.apply(jsList, _jsDirs[key])
}
var imgList = [
'img/love-hate.svg',
'img/works/disap.png',
'img/works/disap-icon-blur.png',
'img/works/sorate.png',
'img/works/sorate-icon-blur.png',
'img/works/eksenlive.png',
'img/works/eksenlive-icon-blur.png',
'img/works/eksenplus.png',
'img/works/eksenplus-icon-blur.png',
'img/works/vdf.png',
'img/works/vdf-icon-blur.png',
'img/works/tickr.png',
'img/works/tickr-icon-blur.png',
'img/works/more.png',
'img/works/more-icon-blur.png',
'img/lab/gravitional-lensing.png',
'img/lab/h-atom.png',
'img/lab/charttransition.png',
'img/lab/cssplane.png',
'img/lab/jquery-aim.png',
'img/lab/rating-analysis.png',
'img/lab/yesno.png',
'img/lab/colorwavelengths.png',
];
// delay each image and append the timestamp to prevent caching
loader = new PxLoader();
for (var i = 0; i < imgList.length; i++) {
var pxImage = new PxLoaderImage(imgList[i]);
pxImage.imageNumber = i + 1;
loader.add(pxImage);
}
var pathLength = 440;
var circleSvg = document.getElementById('loading-circle');
loader.addProgressListener(function(e) {
imgProgress = (e.completedCount / e.totalCount) * 50;
updateProgress();
});
loader.start();
var cssCount = 0;
LazyLoad.css(cssList, function() {
cssProgress = 20*(++cssCount)/cssList.length;
updateProgress();
});
var jsCount = 0;
LazyLoad.js(jsList, function() {
jsProgress = 30*(++jsCount)/jsList.length;
updateProgress();
});
function updateProgress(){
var totalRatio = cssProgress + jsProgress + imgProgress;
if( Math.abs(totalRatio - 100) < 0.05 ){
Portfolio.start();
}
var currLength = pathLength - pathLength * totalRatio/100;
circleSvg.style.strokeDasharray = pathLength + 'px, ' + currLength + 'px'
}
window.res = {
js: jsList,
css: cssList,
img: imgList
}
});