We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 030985d commit a1b47e8Copy full SHA for a1b47e8
src/js/01-nav.js
@@ -151,11 +151,10 @@
151
}
152
153
function scrollItemToMidpoint (panel, item) {
154
- var itemRect = item.getBoundingClientRect()
+ if (panel.scrollHeight === panel.clientHeight) return // not scrollable
155
var panelRect = panel.getBoundingClientRect()
156
- var currentOffsetTop = itemRect.top - panelRect.top + panel.scrollTop
157
- var targetOffsetTop = (panelRect.height - itemRect.height) * 0.5
158
- panel.scrollTop = Math.max(0, (currentOffsetTop - targetOffsetTop).toFixed())
+ var linkRect = item.getBoundingClientRect()
+ panel.scrollTop += Math.round(linkRect.top - panelRect.top - (panelRect.height - linkRect.height) * 0.5)
159
160
161
function find (from, selector) {
0 commit comments