1
0
mirror of https://github.com/musix-org/musix-oss synced 2024-12-24 11:13:18 +00:00
musix-oss/node_modules/ref/docs/scripts/main.js

26 lines
572 B
JavaScript
Raw Normal View History

2020-03-03 20:30:50 +00:00
/**
* Animated scroll to named anchors.
*/
$(document.body).on('click', 'a', function () {
var href = $(this).attr('href')
if (href[0] === '#') {
scrollTo(href)
window.history && history.pushState({}, name, href)
return false
}
})
function scrollTo (hash) {
var name = hash.substring(1)
var target = $('a[name="' + name + '"]')
if (target.length) {
$('html, body').animate({ scrollTop: target.offset().top }
, { duration: 500, easing: 'swing'})
} else {
console.log('documentation not written: %s', name)
}
return target
}