aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/resources/dokka/scripts
diff options
context:
space:
mode:
authorMarcin Aman <maman@virtuslab.com>2020-08-04 19:01:30 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-08-10 09:47:23 +0200
commit49c9bcc586abb7c78f569526a05fea97da86993d (patch)
tree6ec9de732dbc8dcb50885963ff1bfde6d23023e0 /plugins/base/src/main/resources/dokka/scripts
parent632a497ac47150cab9c00bff6b81060af089a908 (diff)
downloaddokka-49c9bcc586abb7c78f569526a05fea97da86993d.tar.gz
dokka-49c9bcc586abb7c78f569526a05fea97da86993d.tar.bz2
dokka-49c9bcc586abb7c78f569526a05fea97da86993d.zip
Highlight anchor
Diffstat (limited to 'plugins/base/src/main/resources/dokka/scripts')
-rw-r--r--plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js12
1 files changed, 12 insertions, 0 deletions
diff --git a/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js b/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js
index f0e08f48..78d65333 100644
--- a/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js
+++ b/plugins/base/src/main/resources/dokka/scripts/platformContentHandler.js
@@ -3,6 +3,8 @@ filteringContext = {
restrictedDependencies: [],
activeFilters: []
}
+let highlightedAnchor;
+
window.addEventListener('load', () => {
document.querySelectorAll("div[data-platform-hinted]")
.forEach(elem => elem.addEventListener('click', (event) => togglePlatformDependent(event,elem)))
@@ -22,6 +24,11 @@ window.addEventListener('load', () => {
window.onhashchange = handleAnchor
function handleAnchor() {
+ if(highlightedAnchor){
+ highlightedAnchor.classList.remove('anchor-highlight')
+ highlightedAnchor = null;
+ }
+
let searchForTab = function(element) {
if(element && element.hasAttribute) {
if(element.hasAttribute("data-togglable")) return element;
@@ -37,6 +44,11 @@ function handleAnchor() {
if (tab) {
let found = document.querySelector('.tabs-section > .section-tab[data-togglable="' + tab.getAttribute("data-togglable") + '"]')
toggleSections(tab)
+ const content = element.nextElementSibling
+ if(content){
+ content.classList.add('anchor-highlight')
+ highlightedAnchor = content
+ }
element.scrollIntoView({behavior: "smooth"})
}
}