forked from jgthms/css-reference
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
26 lines (22 loc) · 776 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
document.addEventListener('DOMContentLoaded', function() {
// Logo
var $logo = document.getElementById('logo');
$logo.addEventListener('click', function(event) {
event.preventDefault();
history.replaceState('', document.title, ' ');
window.scrollTo(0,0);
});
// Hashes
var $hashes = document.querySelectorAll('.hash, .menu-list-ul li a');
Array.prototype.forEach.call($hashes, function($el) {
$el.addEventListener('click', function(event) {
event.preventDefault();
var propertyName = $el.dataset.propertyName;
var $target = document.getElementById($el.dataset.propertyName);
history.replaceState('', document.title, '#' + propertyName);
if ($target) {
$target.scrollIntoView();
}
});
});
});