-
Notifications
You must be signed in to change notification settings - Fork 0
/
home.html
1593 lines (1326 loc) · 58.6 KB
/
home.html
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Space+Mono" rel="stylesheet">
<link href = "main2.css" rel = "stylesheet">
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="https://www.youtube.com/iframe_api"></script>
<script src = "https://cdnjs.cloudflare.com/ajax/libs/gsap/2.1.1/TweenMax.min.js"></script>
<title>A Pale Blue Dot</title>
</head>
<body>
<div class = "intro">
<div class = "text-container">
<div class = "top">
<div class = "top-text">Y</div><div class = "o">ou</div><div class = "top-text">'</div><div class = "o">r</div><div class = "top-text">e</div>
<div class = "top-text">aliv</div><div class = "o">e r</div><div class = "top-text">ight <div class = "o">t</div>his second.</div>
</div>
<div class = "bottom">
<div class = "bottom-text">That's</div> <div class = "bottom-text">an</div> <div class = "o2">a</div><div class = "bottom-text">mazing</div> <div class = "o2">th</div><div class = "bottom-text">ing.</div>
</div>
</div>
</div>
<div id="topnav">
</div>
<div class="container">
<div class="box-1">
<div class="slide0">
<div class="stickman">
<div class="head"></div>
<div class="body">
<div class="arm" id="left"></div>
<div class="arm" id="right"></div>
<div class="leg" id="left"></div>
<div class="leg" id="right"></div>
</div>
</div>
<!--<div class="circle"></div>-->
<canvas id="c"></canvas>
<div class="slide-0-textbox">
<div class = "large-text">Exploring the Earth & the Cosmos</div>
<div class = "text">This site is currently under construction. Yeah. Right now.</div>
</div>
</div><!--
--><div class = "slide1">
<div class = "pale-text">
WHAT IS
</div>
<div class = "para1">
It has been said that astronomy
is a humbling and character-building experience. There is
perhaps no better demonstration of the folly of human conceits
than this distant image of our tiny world. To me, it underscores
our responsibility to deal more kindly with one another, and to
preserve and cherish the pale blue dot, the only home we've ever known.
</div>
<div class = "para2-container">
<div class = "pale-text-rotated">
A PALE BLUE DOT?
</div>
<div class = "para2">
This image of Earth is one of 60 frames taken by the Voyager 1
spacecraft on February 14, 1990 from a distance of more than 6
billion kilometers (4 billion miles) and about 32 degrees above
the ecliptic plane. In the image the Earth is a mere point of
light, a crescent only 0.12 pixel in size. Our planet was caught
in the center of one of the scattered light rays resulting from
taking the image so close to the Sun. This image is part of
Voyager 1's final photographic assignment which captured
family portraits of the Sun and planets.
</div>
</div>
<img src = "images/pale-blue-dot.jpeg" class = "pale-image" >
<!--Look again at that dot. That's here. That's home. that's us
<div id="container">
<div id="inner">
<div class="demo-img">
<div class="demo-overlay">
</div>
</div>
</div>
</div>
<div id="container">
<div id="inner">
<img src = "images/pale_blue_dot_image.jpg" class = "pale-image-bottom" onmouseover = "textIn()" onmouseout = "textOut()">
</div>
</div>-->
<!-- <div class = "text-in-container">
<div class = "text-inside2">
A picture of Earth from space
</div>
<div class = "text-in">
<div class = "text-inside">
<br>Look again at that dot. <br>That's here. That's home.
</div>
</div>
</div>
<div class = "sagan">Sagan's Speech</div>
<div class = "sagan-wrapper">
<div class = "sagan-click">by clicking here</div>
<div class = "sagan-arrow" style = "transition: 1s; display: inline-block; vertical-align: bottom;">-></div>
</div>
<div class = "bars-container" onclick = "pauseState()" onmouseover = "barsShine()" onmouseout = "barsDim()">
<div id = "bars" >
</div>
</div>
<div class = "sagan-speech">
LISTEN TO
</div>
<div id="video-placeholder" style = "opacity: 0; pointer-events: none; position: absolute;"></div>
-->
</div><!--
--><div class = "slide2">
<div class = "text-wrapper-container" onmouseover = "slow()" onmouseout = "slow()">
<div class = "text-wrapper">
You know where we are now, but, how did we get here? You know where we are now, but, how did we get here?
</div>
</div>
</div>
<div class = "slide3">
<div class = "slide3-container">
<img src="images/the-big-bang.jpg" height = "380vh" class = "universe-image">
<br>
<div class = "universe">THE UNIVERSE</div>
was formed in the Big Bang almost 14 billion years ago.
</div>
</div><!--
--><div class = "slide4">
<div class = "slide4-container">
<div class = "alien" onclick = "alienFunction()">👽🌌</div>
<br>
<b class = "alien-question">How many years after the Big Bang was our solar system formed?</b>
<br>
<div class = "outer">
<div class = "box a" onclick = "right()">
4 billion
</div><!--
--><div class = "box b" onclick = "wrong()">
1 million
</div>
</div>
</div>
</div><!--
--><div class = "slide5">
<div class = "slide5-container" onclick = "pause()">
<table class = "tab" >
<tr>
<td onmouseover = "newton()">
If I have seen further than others, it is by standing upon the shoulders of giants.
<br>
<div class = "quote-name">-Isaac Newton</div>
<img src = "images/newton.jpg" alt = "picture of Isaac Newton" class = "newton" id ="slide5">
</td>
</tr>
<tr>
<td onmouseover = "hawking()">
Intelligence is the ability to adapt to change.
<br>
<div class = "quote-name">-Stephen Hawking</div>
<img src = "images/hawking.jpg" alt = "picture of Stephen Hawking" class = "hawking"id ="slide5">
</td>
</tr>
<tr>
<td onmouseover = "tyson()">
Knowing how to think empowers you far beyond those who know only what to think.
<br>
<div class = "quote-name">-Neil deGrasse Tyson</div>
<img src = "images/neil-degrasse-tyson.jpg" alt = "picture of Neil deGrasse Tyson" class = "tyson"id ="slide5">
</td>
</tr>
<tr>
<td onmouseover = "sagan()">
We're made of star stuff. We are a way for the cosmos to know itself.
<br>
<div class = "quote-name">-Carl Sagan</div>
<img src = "images/carl-sagan.jpg" alt = "picture of Carl Sagan" class = "sagan"id ="slide5">
</td>
</tr>
<tr>
<td onmouseover = "einstein()">
Imagination is more important than knowledge.
<br>
<div class = "quote-name">-Albert Einstein</div>
<img src = "images/einstein.jpg" alt = "picture of Albert Einstein" class = "einstein"id ="slide5">
</td>
</tr>
<tr>
<td onmouseover = "newton()">
If I have seen further than others, it is by standing upon the shoulders of giants.
<br>
<div class = "quote-name">-Isaac Newton</div>
<img src = "images/newton.jpg" alt = "picture of Isaac Newton" class = "newton2"id ="slide5">
</td>
</tr>
<tr>
<td onmouseover = "hawking()">
Intelligence is the ability to adapt to change.
<br>
<div class = "quote-name">-Stephen Hawking</div>
<img src = "images/hawking.jpg" alt = "picture of Stephen Hawking" class = "hawking2"id ="slide5">
</td>
</tr>
<tr>
<td onmouseover = "tyson()">
Knowing how to think empowers you far beyond those who know only what to think.
<br>
<div class = "quote-name">-Neil deGrasse Tyson</div>
<img src = "images/neil-degrasse-tyson.jpg" alt = "picture of Neil deGrasse Tyson" class = "tyson2"id ="slide5">
</td>
</tr>
<tr>
<td onmouseover = "sagan()">
We're made of star stuff. We are a way for the cosmos to know itself.
<br>
<div class = "quote-name">-Carl Sagan</div>
<img src = "images/carl-sagan.jpg" alt = "picture of Carl Sagan" class = "sagan2"id ="slide5">
</td>
</tr>
<tr>
<td onmouseover = "einstein()">
Imagination is more important than knowledge.
<br>
<div class = "quote-name">-Albert Einstein</div>
<img src = "images/einstein.jpg" alt = "picture of Albert Einstein" class = "einstein2"id ="slide5">
</td>
</tr>
</table>
</div>
</div>
</div><!--
--><div class="box-2">
<div class = "slide6">
<div class = "climate-change-container">
<img src = "images/climate-change-graph-cropped.jpeg" class = "graph">
<img src = "images/global-temperature.png" class = "graph-temp">
<!--https://climate.nasa.gov/evidence/-->
<div class = "climate-change-text">
Does climate change exist?
<div class = "climate-change-text-small">
Ice sheets are shrinking... Oceans are warming...
<a href = "https://climate.nasa.gov/news/937/warming-ocean-causing-most-antarctic-ice-shelf-mass-loss/"
class = "global-temps" onmouseover = "heatGraph()" onmouseout = "heatGraph()" target = "none">
Global temperatures are rising...
</a>
</div>
</div>
</div>
</div><!--
--><div class = "slide7">
<div class = "book-container">
These books will change the way you view the world.
</div>
<div class = "overall">
<a href = "https://www.amazon.com/Astrophysics-People-Hurry-deGrasse-Tyson/dp/0393609391/ref=sr_1_1?crid=O0BHXGYQQUI2&keywords=astrophysics+for+people+in+a+hurry&qid=1553138129&s=gateway&sprefix=astrophys%2Caps%2C156&sr=8-1"
target = "none"><img id = "slide7" src = "images/astrophysics-for.jpg" class = "astrophysics-for"></a>
<a href = "https://www.amazon.com/Lessons-21st-Century-Yuval-Harari/dp/0525512179/ref=sr_1_1_sspa?keywords=sapiens&qid=1553138149&s=gateway&sr=8-1-spons&psc=1"
target = "none"><img id = "slide7" src = "images/sapiens.jpg" class = "sapiens"></a>
<a href = "https://www.amazon.com/Androids-Dream-Electric-Sheep-inspiration/dp/0345404475/ref=sr_1_1?crid=3VZSQBR6XF725&keywords=do+androids+dream+of+electric+sheep&qid=1553138164&s=gateway&sprefix=do+a%2Caps%2C171&sr=8-1"
target = "none"><img id = "slide7" src = "images/do-androids.jpg" class = "do-androids"></a>
<a href = "https://www.amazon.com/Elegant-Universe-Superstrings-Dimensions-Ultimate/dp/039333810X/ref=sr_1_1?keywords=the+elegant+universe&qid=1553138192&s=gateway&sr=8-1"
target = "none"><img id = "slide7" src = "images/the-elegant.jpg" class = "the-elegant"></a>
<a href = "https://www.amazon.com/Fahrenheit-451-Ray-Bradbury/dp/1451673310/ref=sr_1_1?keywords=fahrenheit+451&qid=1553138209&s=gateway&sr=8-1"
target = "none"><img id = "slide7" src = "images/fahrenheit-451.jpg" class = "fahrenheit-451"></a>
</div>
</div>
<div class="questions-container">
<div class="question-heading">WILL YOU BE THE ONE TO ANSWER THESE QUESTIONS?</div>
<div class="questions">
<div class="question">If we ever find extraterrestrial life, what will the society look like?</div>
</div>
<div class="smqb">Show more <div class="down-triangle"></div></div>
<div class="replay-btn">Replay</div>
</div>
<!--
<div class = "slide8">
</div>
<div class = "slide9">
</div>
<div class = "slide610">
</div>
-->
</div>
</div>
<script>
// ===========================================================
// See tutorial at :
// https://css-tricks.com/animate-a-container-on-mouse-over-using-perspective-and-transform/
// ===========================================================
(function() {
// Init
var container = document.getElementById("container"),
inner = document.getElementById("inner");
// Mouse
var mouse = {
_x: 0,
_y: 0,
x: 0,
y: 0,
updatePosition: function(event) {
var e = event || window.event;
this.x = e.clientX - this._x ;
this.y = (e.clientY - this._y) * -1 ;
},
setOrigin: function(e) {
this._x = e.offsetLeft + Math.floor(e.offsetWidth / 2);
this._y = e.offsetTop + Math.floor(e.offsetHeight / 2);
},
show: function() {
return "(" + this.x + ", " + this.y + ")";
}
};
// Track the mouse position relative to the center of the container.
mouse.setOrigin(container);
//----------------------------------------------------
var counter = 0;
var refreshRate = 10;
var isTimeToUpdate = function() {
return counter++ % refreshRate === 0;
};
//----------------------------------------------------
var onMouseEnterHandler = function(event) {
update(event);
};
var onMouseLeaveHandler = function() {
inner.style = "";
};
var onMouseMoveHandler = function(event) {
if (isTimeToUpdate()) {
update(event);
}
};
//----------------------------------------------------
var update = function(event) {
mouse.updatePosition(event);
updateTransformStyle(
(mouse.y / inner.offsetHeight / 2).toFixed(2),
(mouse.x / inner.offsetWidth / 2).toFixed(2)
);
};
var updateTransformStyle = function(x, y) {
var style = "rotateX(" + x + "deg) rotateY(" + y + "deg)";
inner.style.transform = style;
inner.style.webkitTransform = style;
inner.style.mozTranform = style;
inner.style.msTransform = style;
inner.style.oTransform = style;
};
//--------------------------------------------------------
container.onmousemove = onMouseMoveHandler;
container.onmouseleave = onMouseLeaveHandler;
container.onmouseenter = onMouseEnterHandler;
})();
//buttong hover attract
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
var HoverButton =
/*#__PURE__*/
function () {
function HoverButton(el) {
_classCallCheck(this, HoverButton);
this.el = el;
this.hover = false;
this.calculatePosition();
this.attachEventsListener();
}
_createClass(HoverButton, [{
key: "attachEventsListener",
value: function attachEventsListener() {
var _this = this;
window.addEventListener('mousemove', function (e) {
return _this.onMouseMove(e);
});
window.addEventListener('resize', function (e) {
return _this.calculatePosition(e);
});
}
}, {
key: "calculatePosition",
value: function calculatePosition() {
TweenMax.set(this.el, {
x: 0,
y: 0,
scale: 1
});
const box = this.el.getBoundingClientRect();
this.x = box.left + box.width * 0.5;
this.y = box.top + box.height * 0.5;
this.width = box.width;
this.height = box.height;
}
}, {
key: "onMouseMove",
value: function onMouseMove(e) {
let hover = false;
let hoverArea = this.hover ? 0.7 : 0.5;
let x = e.clientX - this.x;
let y = e.clientY - this.y;
let distance = Math.sqrt(x * x + y * y);
if (distance < this.width * hoverArea) {
hover = true;
if (!this.hover) {
this.hover = true;
}
this.onHover(e.clientX, e.clientY);
}
if (!hover && this.hover) {
this.onLeave();
this.hover = false;
}
}
}, {
key: "onHover",
value: function onHover(x, y) {
TweenMax.to(this.el, 0.4, {
x: (x - this.x) * 0.4,
y: (y - this.y) * 0.4,
scale: 1.15,
ease: Power2.easeOut
});
this.el.style.zIndex = 10;
}
}, {
key: "onLeave",
value: function onLeave() {
TweenMax.to(this.el, 0.7, {
x: 0,
y: 0,
scale: 1,
ease: Elastic.easeOut.config(1.2, 0.4)
});
this.el.style.zIndex = 1;
}
}]);
return HoverButton;
}();
//var tester = document.querySelector('.bars-container');
//new HoverButton(tester);
</script>
<script>
//slide1
var textInBoolean = true;
function textIn() {
document.querySelector('.text-inside').style.transform = "translateX(0vh)";
//document.querySelector('.pale-image-bottom').style.filter = "sepia(100%)";
setTimeout(function myFuntion() {
//document.querySelector('.pale-image-bottom').style.filter = "sepia(0%)";
}, 500);
}
function textOut() {
if (textInBoolean) {
document.querySelector('.text-inside').style.transform = "translateX(40vh)";
textInBoolean = false;
}
else {
document.querySelector('.text-inside').style.transform = "translateX(-40vh)";
textInBoolean = true;
}
}
var player,
time_update_interval = 0;
function onYouTubeIframeAPIReady() {
player = new YT.Player('video-placeholder', {
width: 0,
height: 0,
videoId: 'wupToqz1e2g'
});
}
// Playback
var booleanAudio = true;
$('#bars').on('click', function () {
if (booleanAudio) {
player.playVideo();
booleanAudio = false;
}
else {
player.pauseVideo();
booleanAudio = true;
}
});
function createAudio() {
var bar = document.querySelector('#bars');
var left = -3;
for (var i = 0; i < 10; i++) {
var div = document.createElement("div");
div.classList.add('bar' + i);
left += 4;
var animDuration = 400 + Math.random()*400;
div.style = "left:" + left + "px; animation: sound " + animDuration + "ms -800ms linear infinite alternate; background: #42f4e8; bottom: 1px; height: 3px; position: absolute; width: 3px; ";
bar.appendChild(div);
}
}
createAudio();
setTimeout(pauseState, 10);
var firstClick = true;
var first = true;
function pauseState(){
//document.querySelector('.bar0').style = "height: 10px;"
if (firstClick) {
var left2 = -3;
for (var i = 0; i < 10; i++) {
left2 += 4;
//document.querySelector('.bar' + i).style = "opacity: .35; left: " + left2 + "px; animation: sound " + (100) + "ms linear 1 backwards alternate; background: #E20074; bottom: 1px; height: 3px; position: absolute; width: 3px;";
document.querySelector('.bar' + i).style.webkitAnimationPlayState = "paused";
}
//player.pauseVideo();
document.querySelector('#bars').style.filter = "brightness(50%)";
firstClick = false;
}
else {
var left = -3;
for (var i = 0; i < 10; i++) {
left += 4;
var animDuration = 400 + Math.random()*400;
//document.querySelector('.bar' + i).style = "left:" + left + "px; animation: sound " + animDuration + "ms -800ms linear infinite alternate; background: #E20074; bottom: 1px; height: 3px; position: absolute; width: 3px; ";
document.querySelector('.bar' + i).style.webkitAnimationPlayState = "running";
document.querySelector('#bars').style.webkitAnimationPlayState = "paused";
}
if (first) {
document.querySelector('.sagan').style.transform = "translateX(20vh)";
document.querySelector('.sagan-click').style.transform = "translateY(-10vh)";
document.querySelector('.sagan-arrow').style.transform = "translateY(-10vh)";
first = false;
}
//player.playVideo();
document.querySelector('#bars').style.filter = "brightness(100%)";
firstClick = true;
}
}
function barsShine() {
for (var i = 0; i < 10; i++) {
//document.querySelector('.bar' + i).style.filter = "brightness(100%)";
}
document.querySelector('#bars').style.animation = "none";
}
function barsDim() {
for (var i = 0; i < 10; i++) {
//document.querySelector('.bar' + i).style.filter = "brightness(50%)";
}
//document.querySelector('#bars').style.webkitAnimationPlayState = "running";
}
</script>
<script type="text/javascript">
var delay = 5000;
setTimeout(function() {
//document.querySelector('.top-text').style = "transform: translate(-60px) !important;";
//document.querySelector('.bottom-text').style = "transform: translate(-60px) !important;";
}, delay)
const scrollFactor = 0.3; //sets scroll speed
//event listener to scroll on mouse wheel or laptop equivalent
window.addEventListener("wheel", function(e) {
var target = e.deltaY*scrollFactor;
var container = document.querySelector(".container");
var box1 = container.firstElementChild;
var box2 = container.lastElementChild;
var trans1 = box1.style.transform;
var trans2 = box2.style.transform;
var currX1 = parseFloat(trans1.substring(trans1.indexOf("(")+1, trans1.indexOf("px"))) || parseFloat(window.getComputedStyle(document.querySelector(".box-1")).transform.split(",")[4]);
var currX2 = parseFloat(trans2.substring(trans2.indexOf("(")+1, trans2.indexOf("px"))) || parseFloat(window.getComputedStyle(document.querySelector(".box-2")).transform.split(",")[4]);
box1.style.transform = "translateX("+(currX1+target)+"px)";
box2.style.transform = "translateX("+(currX2+target)+"px)";
if((currX1 + target)<-box1.clientWidth/2) {
//in the second half of box 1
//move box 2 to the right side of box 1
if(box1.getBoundingClientRect().left > box2.getBoundingClientRect().left) {
box2.style.transform = "translateX("+(box1.getBoundingClientRect().right)+"px)";
return;
}
} else {
//in the first half of box 1
if(box1.getBoundingClientRect().left < box2.getBoundingClientRect().left) {
box2.style.transform = "translateX("+(-box2.clientWidth+box1.getBoundingClientRect().left)+"px)";
return;
}
}
if((currX2 + target)<-box2.clientWidth/2) {
//in the second half of box 2
if(box1.getBoundingClientRect().left < box2.getBoundingClientRect().left) {
box1.style.transform = "translateX("+(box2.getBoundingClientRect().left+box2.clientWidth)+"px)";
return;
}
} else {
//in the first half of box 2
if(box1.getBoundingClientRect().left > box2.getBoundingClientRect().left) {
box1.style.transform = "translateX("+(box2.getBoundingClientRect().left-box1.clientWidth)+"px)";
console.log(box1.style.transform);
return;
}
}
});
//arrow key movement
var sep = 100;
document.addEventListener('keydown', function(e) {
var code = e.which || e.keyCode;
if (code == '38') {
// Up
document.body.style = "filter: saturate(" + sep + "%);";
if (sep <10000) {
sep *= 10;
}
console.log('up');
}
else if (code == '40') {
// Down
document.body.style = "filter: saturate(" + sep + "%);";
if (sep > 10) {
sep /= 10;
}
}
else if (code == '37') {
// Left
console.log("left");
}
else if (code == '39') {
// Right
console.log("right");
}
});
//Carl Sagan recording player
var getaudio = $('#player')[0],
mouseovertimer,
audiostatus = 'off',
playerControls = ".player-controls";
$(document).on('mouseenter', playerControls, function() {
if (!mouseovertimer) {
mouseovertimer = window.setTimeout(function() {
mouseovertimer = null;
if (!$(playerControls).hasClass("playing")) {
getaudio.load();
getaudio.play();
$(playerControls).addClass('playing');
return false;
}
}, 2500);
}
});
$(document).on('mouseleave', playerControls, function() {
if (mouseovertimer) {
window.clearTimeout(mouseovertimer);
mouseovertimer = null;
}
});
$(document).on('click touch', playerControls, function(e) {
e.preventDefault();
if (!$(playerControls).hasClass("playing")) {
if (audiostatus == 'off') {
$(playerControls).addClass('playing');
getaudio.load();
getaudio.play();
window.clearTimeout(mouseovertimer);
audiostatus = 'on';
return false;
} else if (audiostatus == 'on') {
$(playerControls).addClass('playing');
getaudio.play();
}
} else if ($(playerControls).hasClass("playing")) {
getaudio.pause();
$(playerControls).removeClass('playing');
window.clearTimeout(mouseovertimer);
audiostatus = 'on';
}
return false;
});
$('#player').on('ended', function() {
$(playerControls).removeClass('playing');
audiostatus = 'off';
});
//infinite text (slide3) slow
var slowBoolean = true;
function slow() {
if (slowBoolean) {
//document.querySelector('.text-wrapper').style = "animation-play-state: paused;";
document.querySelector('.slide3').style = "border-left: .4vh solid #42f4d7;";
document.querySelector('.slide1').style = "border-right: .4vh solid #42f4d7;";
setTimeout(function() {
//document.querySelector('.text-wrapper').style = "word-spacing: auto;";
}, 500);
slowBoolean = false;
}
else {
//document.querySelector('.text-wrapper').style = "animation-play-state: running;";
document.querySelector('.slide3').style = "border-left: .4vh solid white;";
document.querySelector('.slide1').style = "border-right: .4vh solid white;";
slowBoolean = true;
}
}
//slide5 js
function newton(){
document.querySelector('.newton').style = "visibility: visible;";
document.querySelector('.newton2').style = "visibility: visible;";
}
function hawking(){
document.querySelector('.hawking').style = "visibility: visible;";
document.querySelector('.hawking2').style = "visibility: visible;";
}
function tyson(){
document.querySelector('.tyson').style = "visibility: visible;";
document.querySelector('.tyson2').style = "visibility: visible;";
}
function sagan(){
document.querySelector('.sagan').style = "visibility: visible;";
document.querySelector('.sagan2').style = "visibility: visible;";
}
function einstein(){
document.querySelector('.einstein').style = "visibility: visible;";
document.querySelector('.einstein2').style = "visibility: visible;";
}
var boolean = true;
function pause() {
if (boolean){
document.querySelector('.tab').style = "animation-play-state: paused;";
boolean= false;
}
else {
document.querySelector('.tab').style = "animation-play-state: running;";
boolean=true;
}
}
//slide6 js
var bool = true;
function heatGraph() {
if (bool) {
document.querySelector('.graph').style = "opacity: 0;";
document.querySelector('.graph-temp').style = "opacity: 1;";
bool = false;
}
else {
document.querySelector('.graph').style = "opacity: 1;";
document.querySelector('.graph-temp').style = "opacity: 0;";
bool = true;
}
}
//slide7
var lFollowX = 0,
lFollowY = 0,
x = 0,
y = 0,
friction = 1 / 35;
function moveBackground() {
x += (lFollowX - x) * friction;
y += (lFollowY - y) * friction;
translate = 'translate(' + x + 'px, ' + y + 'px) scale(1)';
$('.overall').css({
'-webit-transform': translate,
'-moz-transform': translate,
'transform': translate
});
window.requestAnimationFrame(moveBackground);
}
$(window).on('mousemove click', function(e) {
var lMouseX = Math.max(-100, Math.min(100, $(window).width() / 2 - e.clientX));
var lMouseY = Math.max(-100, Math.min(100, $(window).height() / 2 - e.clientY));
lFollowX = (20 * lMouseX) / 100; // 100 : 12 = lMouxeX : lFollow
lFollowY = (10 * lMouseY) / 100;
});
moveBackground();
//questions slide
var questions = ["Is time travel possible?", "What happens inside a black hole?", "Are tachyons real?", "Why is it harder for a bike to tilt when it’s going faster?", "What existed, if anything, before the Big Bang?"];
var qn = 0;
var showMoreButton = document.querySelector(".smqb");
var replayBtn = document.querySelector(".replay-btn");
showMoreButton.addEventListener("click", function() {
if(qn >= questions.length) {
showMoreButton.style.display = "none";
document.querySelector("div.question").className = "fadeaway";
document.querySelector(".question-heading").classList.add("central-question-heading");
replayBtn.style.display = "block";
replayBtn .classList.add("fadein");
} else {
var div =document.createElement("div");
div.className = "question";
var txt = document.createTextNode(questions[qn]);
div.appendChild(txt);
document.querySelector(".questions").appendChild(div);
var elem = document.getElementsByClassName("question")[0];
var elem2 = document.getElementsByClassName("question")[1];
var pos = 0;
var id = setInterval(frame, .1);
function frame() {
if (pos == screen.height * .1) {
clearInterval(id);
document.querySelector(".questions").removeChild(document.querySelector(".questions").firstElementChild);
elem2.style.top=0;
} else {
pos++;
elem.style.top = -pos*7 + "px";
elem2.style.top = -pos*7 + "px";
}
}
qn++;
}
});
replayBtn.addEventListener("click", function() {
replayBtn.classList.remove("fadein");
replayBtn.style.display = "none";
document.querySelector(".question-heading").classList.remove("central-question-heading");
document.querySelector(".questions").innerHTML = '<div class="question">If we ever find extraterrestrial life, what will the society look like?</div>';
showMoreButton.style.display = "block";
qn = 0;
});
//big bang question interactivity
var boxA = document.querySelector('.box.a');
var boxB = document.querySelector('.box.b');
function right() {
boxB.style = "border-left: none; box-shadow: none; background-color: green; border-radius: 0;";
boxA.style = "border-right: none; margin-right: 0vw;box-shadow: none; background-color: green; border-radius: 0;";
boxB.innerHTML = "is correct";
document.querySelector('.outer').style = "pointer-events: none;";
}
function wrong() {
boxB.innerHTML = "wrong";
boxB.style = "filter: brightness(50%); pointer-events: none;";
}
var bool = true;
function alienFunction() {
if (bool){
document.querySelector('.container').style = "filter: sepia(100%);";
bool = false;
}
else {
document.querySelector('.container').style = "filter: sepia(0%);";
bool = true;
}
}
//fluid simulation
/*
Comments were requested, here we go :)
Here's the rundown:
This script creates a grid of cells and a separate layer of particles that
float on top of the grid. Each cell of the grid holds X and Y velocity
(direction and magnitude) values and a pressure value.
Whenever the user holds down and moves their mouse over the canvas, the velocity
of the mouse is calculated and is used to influence the velocity and pressure in
each cell that was within the defined range of the mouse coordinates. Then, the
pressure change is communicated to all of the neighboring cells of those affected,
adjusting their velocity and pressure, and this is repeated over and over until
the change propogates to all of the cells in the path of the direction of movement.
The particles are randomly placed on the canvas and move according to the
velocity of the grid cells below, similar to grass seed floating on the surface
of water as it's moving. Whenever the particles move off the edge of the canvas,
they are "dropped" back on to the canvas in a random position. The velocity,
however, is "wrapped" around to the opposite edge of the canvas. The slowing
down of the movement is simulated viscosity, which is basically frictional drag
in the liquid.
Let's get started:
--------
This is a self-invoking function. Basically, that means that it runs itself
automatically. The reason for wrapping the script in this is to isolate the
majority of the variables that I define inside from the global scope and
only reveal specific functions and values. It looks like this:
(function(argument) {
alert(argument);
})("Yo.");
and it does the same thing as this:
function thing(argument) {
alert(argument);
}