Avoid using {d.body,doc}.scroll{Top,Left}, use window.scroll[...] instead.
This commit is contained in:
parent
be7a4052fd
commit
738a175f43
@ -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',
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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 @
|
||||
|
||||
@ -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]
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user