Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions src/jump.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,24 @@ const jumper = () => {
function done () {
// account for rAF time rounding inaccuracies
window.scrollTo(0, start + distance)

// if scrolling to an element, and accessibility is enabled
if (element && a11y) {
// add tabindex indicating programmatic focus
element.setAttribute('tabindex', '-1')

// focus the element
element.focus()
}

// if it exists, fire the callback
if (typeof callback === 'function') {
callback()
}

// reset time for next jump
timeStart = false
window.requestAnimationFrame(() => {
// if scrolling to an element, and accessibility is enabled
if (element && a11y) {
// add tabindex indicating programmatic focus
element.setAttribute('tabindex', '-1')

// focus the element
element.focus()
}

// if it exists, fire the callback
if (typeof callback === 'function') {
callback()
}

// reset time for next jump
timeStart = false
})
}

// API
Expand Down