This commit is contained in:
Brittany Chiang
2017-12-24 23:55:35 -05:00
parent 0078156d5b
commit 165a8799e7
8 changed files with 101 additions and 17 deletions

View File

@@ -1 +1,77 @@
$(function(){function e(){l.classList.add("wave"),setTimeout(function(){l.classList.remove("wave")},2e3)}const t=new Date,o=t.getHours(),n=o>=19||o<=7,c=document.querySelector("body"),s=document.getElementById("toggle"),i=document.getElementById("switch");n&&(i.checked=!0,c.classList.add("night")),s.addEventListener("click",function(){const e=i.checked;e?c.classList.remove("night"):c.classList.add("night")});const r=document.querySelector(".intro").offsetHeight,a=document.getElementById("top-button"),d=$("#top-button");window.addEventListener("scroll",function(){window.scrollY>r?d.fadeIn():d.fadeOut()},!1),a.addEventListener("click",function(){$("html, body").animate({scrollTop:0},500)});const l=document.querySelector(".emoji.wave-hand");setTimeout(function(){e()},1e3),l.addEventListener("mouseover",function(){l.classList.add("wave")}),l.addEventListener("mouseout",function(){l.classList.remove("wave")}),window.sr=ScrollReveal({reset:!1,duration:600,easing:"cubic-bezier(.694,0,.335,1)",scale:1,viewFactor:.3}),sr.reveal(".background"),sr.reveal(".skills"),sr.reveal(".experience",{viewFactor:.2}),sr.reveal(".featured-projects",{viewFactor:.1}),sr.reveal(".other-projects",{viewFactor:.05})});
$(function() {
const d = new Date();
const hours = d.getHours();
const nighttime = (hours >= 19) || (hours <= 7); // 7pm <= hours <= 7am
const body = document.querySelector('body');
const toggle = document.getElementById('toggle');
const input = document.getElementById('switch');
if (nighttime) {
input.checked = true;
body.classList.add('night');
}
toggle.addEventListener('click', function() {
const isChecked = input.checked;
if (isChecked) {
body.classList.remove('night');
} else {
body.classList.add('night');
}
});
const introHeight = document.querySelector('.intro').offsetHeight;
const topButton = document.getElementById('top-button');
const $topButton = $('#top-button');
window.addEventListener('scroll', function() {
if (window.scrollY > introHeight) {
$topButton.fadeIn();
} else {
$topButton.fadeOut();
}
}, false);
topButton.addEventListener('click', function() {
$('html, body').animate({scrollTop: 0}, 500);
});
const hand = document.querySelector('.emoji.wave-hand');
function waveOnLoad() {
hand.classList.add('wave');
setTimeout(function() {
hand.classList.remove('wave');
}, 2000);
}
setTimeout(function() { waveOnLoad(); }, 1000);
hand.addEventListener('mouseover', function() {
hand.classList.add('wave');
});
hand.addEventListener('mouseout', function() {
hand.classList.remove('wave');
});
window.sr = ScrollReveal({
reset: false,
duration: 600,
easing: 'cubic-bezier(.694,0,.335,1)',
scale: 1,
viewFactor: 0.3
});
sr.reveal('.background');
sr.reveal('.skills');
sr.reveal('.experience', {viewFactor: 0.2});
sr.reveal('.featured-projects', {viewFactor: 0.1});
sr.reveal('.other-projects', {viewFactor: 0.05});
});