Skip to content

Commit 8b5e908

Browse files
authored
Merge pull request #51 from ashwaniYDV/master
added tilt js and mouse particles
2 parents 4134717 + 02449e0 commit 8b5e908

File tree

8 files changed

+276
-1
lines changed

8 files changed

+276
-1
lines changed

archive.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1387,5 +1387,6 @@ <h3>Previous Sponsors</h3>
13871387

13881388
</main>
13891389
</div>
1390+
<script src="./assets/js/sparkle.js"></script>
13901391
</body>
13911392
</html>

assets/js/sparkle.js

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
var colour="random"; // "random" can be replaced with any valid colour ie: "red"...
2+
var sparkles=900;// increase of decrease for number of sparkles falling
3+
4+
var x=ox=400;
5+
var y=oy=300;
6+
var swide=800;
7+
var shigh=600;
8+
var sleft=sdown=0;
9+
var tiny=new Array();
10+
var star=new Array();
11+
var starv=new Array();
12+
var starx=new Array();
13+
var stary=new Array();
14+
var tinyx=new Array();
15+
var tinyy=new Array();
16+
var tinyv=new Array();
17+
18+
colours=new Array('#ff0000','#00ff00','#ffffff','#ff00ff','#ffa500','#ffff00','#00ff00','#ffffff','ff00ff')
19+
20+
n = 10;
21+
y = 0;
22+
x = 0;
23+
n6=(document.getElementById&&!document.all);
24+
ns=(document.layers);
25+
ie=(document.all);
26+
d=(ns||ie)?'document.':'document.getElementById("';
27+
a=(ns||n6)?'':'all.';
28+
n6r=(n6)?'")':'';
29+
s=(ns)?'':'.style';
30+
31+
if (ns){
32+
for (i = 0; i < n; i++)
33+
document.write('<layer name="dots'+i+'" top=0 left=0 width='+i/2+' height='+i/2+' bgcolor=#ff0000></layer>');
34+
}
35+
36+
if (ie)
37+
document.write('<div id="con" style="position:absolute;top:0px;left:0px"><div style="position:relative">');
38+
39+
if (ie||n6){
40+
for (i = 0; i < n; i++)
41+
document.write('<div id="dots'+i+'" style="position:absolute;top:0px;left:0px;width:'+i/2+'px;height:'+i/2+'px;background:#ff0000;font-size:'+i/2+'"></div>');
42+
}
43+
44+
if (ie)
45+
document.write('</div></div>');
46+
(ns||n6)?window.captureEvents(Event.MOUSEMOVE):0;
47+
48+
function Mouse(evnt){
49+
50+
y = (ns||n6)?evnt.pageY+4 - window.pageYOffset:event.y+4;
51+
x = (ns||n6)?evnt.pageX+1:event.x+1;
52+
}
53+
54+
(ns)?window.onMouseMove=Mouse:document.onmousemove=Mouse;
55+
56+
function animate(){
57+
58+
o=(ns||n6)?window.pageYOffset:0;
59+
60+
if (ie)con.style.top=document.body.scrollTop + 'px';
61+
62+
for (i = 0; i < n; i++){
63+
64+
var temp1 = eval(d+a+"dots"+i+n6r+s);
65+
66+
randcolours = colours[Math.floor(Math.random()*colours.length)];
67+
68+
(ns)?temp1.bgColor = randcolours:temp1.background = randcolours;
69+
70+
if (i < n-1){
71+
72+
var temp2 = eval(d+a+"dots"+(i+1)+n6r+s);
73+
temp1.top = parseInt(temp2.top) + 'px';
74+
temp1.left = parseInt(temp2.left) + 'px';
75+
76+
}
77+
else{
78+
79+
temp1.top = y+o + 'px';
80+
temp1.left = x + 'px';
81+
}
82+
}
83+
84+
setTimeout("animate()",10);
85+
}
86+
87+
animate();
88+
89+
window.onload=function() { if (document.getElementById) {
90+
var i, rats, rlef, rdow;
91+
for (var i=0; i<sparkles; i++) {
92+
var rats=createDiv(3, 3);
93+
rats.style.visibility="hidden";
94+
rats.style.zIndex="999";
95+
document.body.appendChild(tiny[i]=rats);
96+
starv[i]=0;
97+
tinyv[i]=0;
98+
var rats=createDiv(5, 5);
99+
rats.style.backgroundColor="transparent";
100+
rats.style.visibility="hidden";
101+
rats.style.zIndex="999";
102+
var rlef=createDiv(1, 5);
103+
var rdow=createDiv(5, 1);
104+
rats.appendChild(rlef);
105+
rats.appendChild(rdow);
106+
rlef.style.top="2px";
107+
rlef.style.left="0px";
108+
rdow.style.top="0px";
109+
rdow.style.left="2px";
110+
document.body.appendChild(star[i]=rats);
111+
}
112+
set_width();
113+
sparkle();
114+
}}
115+
116+
function sparkle() {
117+
var c;
118+
if (Math.abs(x-ox)>1 || Math.abs(y-oy)>1) {
119+
ox=x;
120+
oy=y;
121+
for (c=0; c<sparkles; c++) if (!starv[c]) {
122+
star[c].style.left=(starx[c]=x)+"px";
123+
star[c].style.top=(stary[c]=y+1)+"px";
124+
star[c].style.clip="rect(0px, 5px, 5px, 0px)";
125+
star[c].childNodes[0].style.backgroundColor=star[c].childNodes[1].style.backgroundColor=(colour=="random")?newColour():colour;
126+
star[c].style.visibility="visible";
127+
starv[c]=50;
128+
break;
129+
}
130+
}
131+
for (c=0; c<sparkles; c++) {
132+
if (starv[c]) update_star(c);
133+
if (tinyv[c]) update_tiny(c);
134+
}
135+
setTimeout("sparkle()", 40);
136+
}
137+
138+
function update_star(i) {
139+
if (--starv[i]==25) star[i].style.clip="rect(1px, 4px, 4px, 1px)";
140+
if (starv[i]) {
141+
stary[i]+=1+Math.random()*3;
142+
starx[i]+=(i%5-2)/5;
143+
if (stary[i]<shigh+sdown) {
144+
star[i].style.top=stary[i]+"px";
145+
star[i].style.left=starx[i]+"px";
146+
}
147+
else {
148+
star[i].style.visibility="hidden";
149+
starv[i]=0;
150+
return;
151+
}
152+
}
153+
else {
154+
tinyv[i]=50;
155+
tiny[i].style.top=(tinyy[i]=stary[i])+"px";
156+
tiny[i].style.left=(tinyx[i]=starx[i])+"px";
157+
tiny[i].style.width="2px";
158+
tiny[i].style.height="2px";
159+
tiny[i].style.backgroundColor=star[i].childNodes[0].style.backgroundColor;
160+
star[i].style.visibility="hidden";
161+
tiny[i].style.visibility="visible"
162+
}
163+
}
164+
165+
function update_tiny(i) {
166+
if (--tinyv[i]==25) {
167+
tiny[i].style.width="1px";
168+
tiny[i].style.height="1px";
169+
}
170+
if (tinyv[i]) {
171+
tinyy[i]+=1+Math.random()*3;
172+
tinyx[i]+=(i%5-2)/5;
173+
if (tinyy[i]<shigh+sdown) {
174+
tiny[i].style.top=tinyy[i]+"px";
175+
tiny[i].style.left=tinyx[i]+"px";
176+
}
177+
else {
178+
tiny[i].style.visibility="hidden";
179+
tinyv[i]=0;
180+
return;
181+
}
182+
}
183+
else tiny[i].style.visibility="hidden";
184+
}
185+
186+
document.onmousemove=mouse;
187+
function mouse(e) {
188+
if (e) {
189+
y=e.pageY;
190+
x=e.pageX;
191+
}
192+
else {
193+
set_scroll();
194+
y=event.y+sdown;
195+
x=event.x+sleft;
196+
}
197+
}
198+
199+
window.onscroll=set_scroll;
200+
function set_scroll() {
201+
if (typeof(self.pageYOffset)=='number') {
202+
sdown=self.pageYOffset;
203+
sleft=self.pageXOffset;
204+
}
205+
else if (document.body && (document.body.scrollTop || document.body.scrollLeft)) {
206+
sdown=document.body.scrollTop;
207+
sleft=document.body.scrollLeft;
208+
}
209+
else if (document.documentElement && (document.documentElement.scrollTop || document.documentElement.scrollLeft)) {
210+
sleft=document.documentElement.scrollLeft;
211+
sdown=document.documentElement.scrollTop;
212+
}
213+
else {
214+
sdown=0;
215+
sleft=0;
216+
}
217+
}
218+
219+
window.onresize=set_width;
220+
function set_width() {
221+
var sw_min=999999;
222+
var sh_min=999999;
223+
if (document.documentElement && document.documentElement.clientWidth) {
224+
if (document.documentElement.clientWidth>0) sw_min=document.documentElement.clientWidth;
225+
if (document.documentElement.clientHeight>0) sh_min=document.documentElement.clientHeight;
226+
}
227+
if (typeof(self.innerWidth)=='number' && self.innerWidth) {
228+
if (self.innerWidth>0 && self.innerWidth<sw_min) sw_min=self.innerWidth;
229+
if (self.innerHeight>0 && self.innerHeight<sh_min) sh_min=self.innerHeight;
230+
}
231+
if (document.body.clientWidth) {
232+
if (document.body.clientWidth>0 && document.body.clientWidth<sw_min) sw_min=document.body.clientWidth;
233+
if (document.body.clientHeight>0 && document.body.clientHeight<sh_min) sh_min=document.body.clientHeight;
234+
}
235+
if (sw_min==999999 || sh_min==999999) {
236+
sw_min=800;
237+
sh_min=600;
238+
}
239+
swide=sw_min;
240+
shigh=sh_min;
241+
}
242+
243+
function createDiv(height, width) {
244+
var div=document.createElement("div");
245+
div.style.position="absolute";
246+
div.style.height=height+"px";
247+
div.style.width=width+"px";
248+
div.style.overflow="hidden";
249+
return (div);
250+
}
251+
252+
function newColour() {
253+
var c=new Array();
254+
c[0]=255;
255+
c[1]=Math.floor(Math.random()*256);
256+
c[2]=Math.floor(Math.random()*(256-c[1]/2));
257+
c.sort(function(){return (0.5 - Math.random());});
258+
return ("rgb("+c[0]+", "+c[1]+", "+c[2]+")");
259+
}
260+
// ]]>

codeofconduct.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,5 +205,6 @@ <h3>Code of Conduct</h3>
205205

206206
</main>
207207
</div>
208+
<script src="./assets/js/sparkle.js"></script>
208209
</body>
209210
</html>

contact.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,5 +245,6 @@ <h3>NWoC Advisory Committee</h3>
245245

246246
</main>
247247
</div>
248+
<script src="./assets/js/sparkle.js"></script>
248249
</body>
249250
</html>

index.html

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@
109109

110110
<main class="mdl-layout__content">
111111
<div class="nwoc-landing-header">
112-
<img class="nwoc-big-logo" src="./images/nwoc-logo.png" />
112+
<img class="nwoc-big-logo js-tilt" data-tilt src="./images/nwoc-logo.png" />
113113
<div class="nwoc-slogan">
114114
<p>NWoC (NJACK Winter of Code) is a program by NJACK (The Official Computer Science Club of IIT Patna) that
115115
helps students understand the paradigm of Open Source contribution and gives them real world software
@@ -519,4 +519,13 @@ <h4>Tell your friends about NWoC</h4>
519519
}());
520520
</script>
521521

522+
<script src="https://cdnjs.cloudflare.com/ajax/libs/tilt.js/1.2.1/tilt.jquery.min.js"></script>
523+
<script>
524+
$('.js-tilt').tilt({
525+
scale: 1.2,
526+
glare: true,
527+
maxGlare: 1
528+
})
529+
</script>
530+
<script src="./assets/js/sparkle.js"></script>
522531
</html>

leaderboard.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,5 +218,6 @@ <h3>NWoC 2020 Leaderboard</h3>
218218

219219
</main>
220220
</div>
221+
<script src="./assets/js/sparkle.js"></script>
221222
</body>
222223
</html>

projects.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,5 +623,6 @@ <h3>NWoC 2020 Projects</h3>
623623

624624
</main>
625625
</div>
626+
<script src="./assets/js/sparkle.js"></script>
626627
</body>
627628
</html>

timeline.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -284,5 +284,6 @@ <h3>Timeline</h3>
284284

285285
</main>
286286
</div>
287+
<script src="./assets/js/sparkle.js"></script>
287288
</body>
288289
</html>

0 commit comments

Comments
 (0)