[src:feat] scroll to URL hash
This commit is contained in:
parent
25b44e8f5c
commit
f246b0e9ba
|
@ -93,6 +93,15 @@ actions.showSpeedReader = () => {
|
||||||
document.body.appendChild(script)
|
document.body.appendChild(script)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
actions.scrollToHash = (hash = null) => {
|
||||||
|
const h = (hash || document.location.hash).replace("#", "")
|
||||||
|
const e = document.getElementById(h) || document.querySelector(`[name="${h}"]`)
|
||||||
|
if (!e) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
e.scrollIntoView({ behavior: "smooth" })
|
||||||
|
}
|
||||||
|
|
||||||
// Surfingkeys-specific actions
|
// Surfingkeys-specific actions
|
||||||
// ----------------------------
|
// ----------------------------
|
||||||
actions.createHint = (selector, action) => () => {
|
actions.createHint = (selector, action) => () => {
|
||||||
|
|
6
keys.js
6
keys.js
|
@ -183,6 +183,12 @@ const maps = {
|
||||||
category: categories.tabs,
|
category: categories.tabs,
|
||||||
description: "Close tab to right",
|
description: "Close tab to right",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
alias: "gh",
|
||||||
|
category: categories.clipboard,
|
||||||
|
description: "Scroll to element targeted by URL hash",
|
||||||
|
callback: actions.scrollToHash,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
|
|
||||||
"amazon.com": [
|
"amazon.com": [
|
||||||
|
|
Loading…
Reference in New Issue