<div class="paragraph">
<p>Nominavi luptatum eos, an vim hinc philosophia intellegebat.
Lorem <code>expetenda</code> pertinacia et nec, wisi illud sonet qui ea.
-Eum an doctus <a href="#">maiestatis efficiantur</a>.
+Eum an doctus <a href="#liber-recusabo">maiestatis efficiantur</a>.
Eu mea inani iriure.</p>
</div>
<div class="listingblock">
</div>
<div class="paragraph">
<p>Cum dicat putant ne.
-Est in reque homero principes, meis deleniti mediocrem ad has.
+Est in <a href="#inline">reque</a> homero principes, meis deleniti mediocrem ad has.
Altera atomorum his ex, has cu elitr melius propriae.
Eos suscipit scaevola at.</p>
</div>
</td>
<td class="content">
<div class="paragraph">
-<p>I wouldn’t try that if I were you.</p>
+<p id="inline">I wouldn’t try that if I were you.</p>
</div>
</td>
</tr>
Eos suscipit scaevola at.</p>
</div>
</div>
-</div>
\ No newline at end of file
+</div>
--- /dev/null
+;(function () {
+ 'use strict'
+
+ var article = document.querySelector('article.doc')
+ var toolbar = document.querySelector('.toolbar')
+
+ function computePosition (el, sum) {
+ if (article.contains(el)) {
+ return computePosition(el.offsetParent, el.offsetTop + sum)
+ } else {
+ return sum
+ }
+ }
+
+ function jumpToAnchor (e) {
+ if (e) {
+ window.location.hash = '#' + this.id
+ e.preventDefault()
+ }
+ window.scrollTo(0, computePosition(this, 0) - toolbar.getBoundingClientRect().bottom)
+ }
+
+ window.addEventListener('load', function jumpOnLoad (e) {
+ var hash, target
+ if ((hash = window.location.hash) && (target = document.getElementById(hash.slice(1)))) {
+ jumpToAnchor.bind(target)()
+ }
+ window.removeEventListener('load', jumpOnLoad)
+ })
+
+ Array.prototype.slice.call(document.querySelectorAll('.doc a[href^="#"]')).forEach(function (el) {
+ var hash, target
+ if ((hash = el.hash.slice(1)) && (target = document.getElementById(hash))) {
+ el.addEventListener('click', jumpToAnchor.bind(target))
+ }
+ })
+})()