Commit 0e85184b798e0dcaa10ed88344b6d6d6527e074c
trying to stop body from scrolling sometimes on anchor link
Matt McKegg committed on 10/1/2017, 10:02:42 PMParent: 7bdf4daf193026068d288618aca064b044b2450b
Files changed
modules/page/html/render/message.js | changed |
modules/page/html/render/message.js | ||
---|---|---|
@@ -117,15 +117,25 @@ | ||
117 | 117 | if (scrollParent) { |
118 | 118 | // ensure context is visible |
119 | 119 | scrollParent.scrollTop = Math.max(0, scrollParent.scrollTop - 100) |
120 | 120 | } |
121 | + | |
122 | + // HACK: sometimes the body gets affected!? Why no just hack it!!! | |
123 | + if (document.body.scrollTop > 0) { | |
124 | + document.body.scrollTop = 0 | |
125 | + } | |
121 | 126 | } |
122 | 127 | |
123 | 128 | function getScrollParent (element) { |
124 | 129 | while (element.parentNode) { |
125 | - if (element.parentNode.scrollTop > 10) { | |
130 | + if (element.parentNode.scrollTop > 10 && isScroller(element.parentNode)) { | |
126 | 131 | return element.parentNode |
127 | 132 | } else { |
128 | 133 | element = element.parentNode |
129 | 134 | } |
130 | 135 | } |
131 | 136 | } |
137 | + | |
138 | +function isScroller (element) { | |
139 | + var value = window.getComputedStyle(element)['overflow-y'] | |
140 | + return (value === 'auto' || value === 'scroll') | |
141 | +} |
Built with git-ssb-web