Fix/1.0.2 (#25)
* Fix regular expression, fixed #23 * Fix repeat binding events * Add content cache * Add changelog
This commit is contained in:
parent
440635aeeb
commit
44a255103c
5 changed files with 48 additions and 20 deletions
19
src/event.js
19
src/event.js
|
|
@ -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()
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue