git ssb

0+

alanz / patchwork



forked from Matt McKegg / patchwork

Commit 0e85184b798e0dcaa10ed88344b6d6d6527e074c

trying to stop body from scrolling sometimes on anchor link

Matt McKegg committed on 10/1/2017, 10:02:42 PM
Parent: 7bdf4daf193026068d288618aca064b044b2450b

Files changed

modules/page/html/render/message.jschanged
modules/page/html/render/message.jsView
@@ -117,15 +117,25 @@
117117 if (scrollParent) {
118118 // ensure context is visible
119119 scrollParent.scrollTop = Math.max(0, scrollParent.scrollTop - 100)
120120 }
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+ }
121126 }
122127
123128 function getScrollParent (element) {
124129 while (element.parentNode) {
125- if (element.parentNode.scrollTop > 10) {
130+ if (element.parentNode.scrollTop > 10 && isScroller(element.parentNode)) {
126131 return element.parentNode
127132 } else {
128133 element = element.parentNode
129134 }
130135 }
131136 }
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