diff --git a/src/General/Header.coffee b/src/General/Header.coffee index ae98518ed..4c76991b1 100644 --- a/src/General/Header.coffee +++ b/src/General/Header.coffee @@ -248,8 +248,8 @@ Header = {top} = post.getBoundingClientRect() unless Conf['Bottom header'] headRect = Header.toggle.getBoundingClientRect() - top += - headRect.top - headRect.height - <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop += top + top -= headRect.top + headRect.height + window.scrollBy 0, top addShortcut: (el) -> shortcut = $.el 'span', diff --git a/src/General/UI.coffee b/src/General/UI.coffee index 7c6c752e0..84bc40a08 100644 --- a/src/General/UI.coffee +++ b/src/General/UI.coffee @@ -63,8 +63,8 @@ UI = do -> # Position mRect = menu.getBoundingClientRect() bRect = button.getBoundingClientRect() - bTop = doc.scrollTop + d.body.scrollTop + bRect.top - bLeft = doc.scrollLeft + d.body.scrollLeft + bRect.left + bTop = window.scrollY + bRect.top + bLeft = window.scrollX + bRect.left cHeight = doc.clientHeight cWidth = doc.clientWidth [top, bottom] = if bRect.top + bRect.height + mRect.height < cHeight diff --git a/src/Images/ImageExpand.coffee b/src/Images/ImageExpand.coffee index 777cceea8..9a4d8dd3f 100644 --- a/src/Images/ImageExpand.coffee +++ b/src/Images/ImageExpand.coffee @@ -59,17 +59,18 @@ ImageExpand = ImageExpand.expand post return ImageExpand.contract post - rect = post.nodes.root.getBoundingClientRect() - return unless rect.top <= 0 or rect.left <= 0 + # Scroll back to the thumbnail when contracting the image # to avoid being left miles away from the relevant post. - {top} = rect - unless Conf['Bottom header'] - headRect = Header.toggle.getBoundingClientRect() - top += - headRect.top - headRect.height - root = <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %> - root.scrollTop += top if rect.top < 0 - root.scrollLeft = 0 if rect.left < 0 + rect = post.nodes.root.getBoundingClientRect() + if rect.top < 0 + y = rect.top + unless Conf['Bottom header'] + headRect = Header.toggle.getBoundingClientRect() + y -= headRect.top + headRect.height + if rect.left < 0 + x = -window.scrollX + window.scrollBy x, y if x or y contract: (post) -> $.rmClass post.nodes.root, 'expanded-image' @@ -109,9 +110,8 @@ ImageExpand = $.addClass post.nodes.root, 'expanded-image' $.rmClass post.file.thumb, 'expanding' return unless prev.top + prev.height <= 0 - root = <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %> curr = post.nodes.root.getBoundingClientRect() - root.scrollTop += curr.height - prev.height + curr.top - prev.top + window.scrollBy 0, curr.height - prev.height + curr.top - prev.top error: -> post = Get.postFromNode @ diff --git a/src/Monitoring/ThreadUpdater.coffee b/src/Monitoring/ThreadUpdater.coffee index 7dab2983a..ceb1a68bd 100644 --- a/src/Monitoring/ThreadUpdater.coffee +++ b/src/Monitoring/ThreadUpdater.coffee @@ -262,7 +262,7 @@ ThreadUpdater = sendEvent() if scroll if Conf['Bottom Scroll'] - <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop = d.body.clientHeight + window.scrollTo 0, d.body.clientHeight else Header.scrollToPost nodes[0]