forked from sindresorhus/sindresorhus.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
36 lines (32 loc) · 920 Bytes
/
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
/* eslint-env browser */
// Helper
const dom = {
select: document.querySelector.bind(document),
selectAll: document.querySelectorAll.bind(document)
};
const injectScript = (source, callback) => {
const script = document.createElement('script');
script.src = source;
script.addEventListener('load', callback);
document.head.appendChild(script);
};
// Unicorn easteregg
dom.select('#unicorn-btn').addEventListener('click', event => {
event.preventDefault();
injectScript('cornify.js', () => {
cornify();
cornify();
setInterval(cornify, 1000);
});
}, {once: true});
// Enable again if I put more stuff on the homepage.
// {
// function hideScrollHint() {
// if (window.scrollY > 100) {
// document.removeEventListener('scroll', hideScrollHint);
// dom.select('#scroll-hint').classList.add('hidden');
// }
// }
//
// document.addEventListener('scroll', hideScrollHint, {passive: true});
// }