forked from groupoid/groupoid.space
-
Notifications
You must be signed in to change notification settings - Fork 0
/
highlight.js
34 lines (29 loc) · 1.09 KB
/
highlight.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
function highlight() {
var code = document.getElementsByTagName('code');
for (var i = 0; i < code.length; i++) {
code[i].innerHTML = code[i].innerHTML
.replace(/([(){}→∀λ,=]+|::=|:=)/g,
'<span class="h__symbol">$1</span>')
.replace(/\b(data|where|module|import|.1|.2|Pi|Sigma|Path|Definition|Type|Prop|Structure|forall|fun|split|let|axiom|in|U)\b(?!:)/g,
'<span class="h__keyword">$1</span>');
}
}
highlight();
var lastScrollPosition = 0;
var ticking = false;
window.addEventListener('scroll', function(e) {
lastScrollPosition = window.scrollY;
if (!ticking) {
window.requestAnimationFrame(function() {
doSomething(lastScrollPosition);
ticking = false;
});
}
ticking = true;
});
var titles = document.querySelector('.header__titles');
var logo = document.querySelector('.header__logo');
function doSomething(scrollPos) {
titles.style.transform = 'translate3d(0px, ' + (scrollPos/2) + 'px, 0px)';
logo.style.transform = 'translate3d(0px, ' + (scrollPos/2) + 'px, 0px)';
}