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()
|
{top} = post.getBoundingClientRect()
|
||||||
unless Conf['Bottom header']
|
unless Conf['Bottom header']
|
||||||
headRect = Header.toggle.getBoundingClientRect()
|
headRect = Header.toggle.getBoundingClientRect()
|
||||||
top += - headRect.top - headRect.height
|
top -= headRect.top + headRect.height
|
||||||
<% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop += top
|
window.scrollBy 0, top
|
||||||
|
|
||||||
addShortcut: (el) ->
|
addShortcut: (el) ->
|
||||||
shortcut = $.el 'span',
|
shortcut = $.el 'span',
|
||||||
|
|||||||
@ -63,8 +63,8 @@ UI = do ->
|
|||||||
# Position
|
# Position
|
||||||
mRect = menu.getBoundingClientRect()
|
mRect = menu.getBoundingClientRect()
|
||||||
bRect = button.getBoundingClientRect()
|
bRect = button.getBoundingClientRect()
|
||||||
bTop = doc.scrollTop + d.body.scrollTop + bRect.top
|
bTop = window.scrollY + bRect.top
|
||||||
bLeft = doc.scrollLeft + d.body.scrollLeft + bRect.left
|
bLeft = window.scrollX + bRect.left
|
||||||
cHeight = doc.clientHeight
|
cHeight = doc.clientHeight
|
||||||
cWidth = doc.clientWidth
|
cWidth = doc.clientWidth
|
||||||
[top, bottom] = if bRect.top + bRect.height + mRect.height < cHeight
|
[top, bottom] = if bRect.top + bRect.height + mRect.height < cHeight
|
||||||
|
|||||||
@ -59,17 +59,18 @@ ImageExpand =
|
|||||||
ImageExpand.expand post
|
ImageExpand.expand post
|
||||||
return
|
return
|
||||||
ImageExpand.contract post
|
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
|
# Scroll back to the thumbnail when contracting the image
|
||||||
# to avoid being left miles away from the relevant post.
|
# to avoid being left miles away from the relevant post.
|
||||||
{top} = rect
|
rect = post.nodes.root.getBoundingClientRect()
|
||||||
unless Conf['Bottom header']
|
if rect.top < 0
|
||||||
headRect = Header.toggle.getBoundingClientRect()
|
y = rect.top
|
||||||
top += - headRect.top - headRect.height
|
unless Conf['Bottom header']
|
||||||
root = <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>
|
headRect = Header.toggle.getBoundingClientRect()
|
||||||
root.scrollTop += top if rect.top < 0
|
y -= headRect.top + headRect.height
|
||||||
root.scrollLeft = 0 if rect.left < 0
|
if rect.left < 0
|
||||||
|
x = -window.scrollX
|
||||||
|
window.scrollBy x, y if x or y
|
||||||
|
|
||||||
contract: (post) ->
|
contract: (post) ->
|
||||||
$.rmClass post.nodes.root, 'expanded-image'
|
$.rmClass post.nodes.root, 'expanded-image'
|
||||||
@ -109,9 +110,8 @@ ImageExpand =
|
|||||||
$.addClass post.nodes.root, 'expanded-image'
|
$.addClass post.nodes.root, 'expanded-image'
|
||||||
$.rmClass post.file.thumb, 'expanding'
|
$.rmClass post.file.thumb, 'expanding'
|
||||||
return unless prev.top + prev.height <= 0
|
return unless prev.top + prev.height <= 0
|
||||||
root = <% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>
|
|
||||||
curr = post.nodes.root.getBoundingClientRect()
|
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: ->
|
error: ->
|
||||||
post = Get.postFromNode @
|
post = Get.postFromNode @
|
||||||
|
|||||||
@ -262,7 +262,7 @@ ThreadUpdater =
|
|||||||
sendEvent()
|
sendEvent()
|
||||||
if scroll
|
if scroll
|
||||||
if Conf['Bottom Scroll']
|
if Conf['Bottom Scroll']
|
||||||
<% if (type === 'crx') { %>d.body<% } else { %>doc<% } %>.scrollTop = d.body.clientHeight
|
window.scrollTo 0, d.body.clientHeight
|
||||||
else
|
else
|
||||||
Header.scrollToPost nodes[0]
|
Header.scrollToPost nodes[0]
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user