Fix/1.0.2 (#25)

* Fix regular expression, fixed #23

* Fix repeat binding events

* Add content cache

* Add changelog
This commit is contained in:
cinwell.li 2016-12-13 22:10:58 +08:00 • committed by GitHub
commit 44a255103c
5 changed files with 48 additions and 20 deletions

View file

@ -39,19 +39,18 @@ export function scrollActiveSidebar () {
}
}
document.querySelector('main .content').addEventListener('scroll', highlight)
const dom = document.querySelector('main .content')
dom.removeEventListener('scroll', highlight)
dom.addEventListener('scroll', highlight)
highlight()
}
function scrollIntoView () {
const id = window.location.hash.match(/#[^#\/]+$/g)
if (!id || !id.length) return
const section = document.querySelector(id[0])
export function scrollIntoView () {
const id = window.location.hash.match(/#[^#\/]+$/g)
if (!id || !id.length) return
const section = document.querySelector(id[0])
if (section) section.scrollIntoView()
}
window.addEventListener('hashchange', scrollIntoView)
scrollIntoView()
if (section) section.scrollIntoView()
}
/**