Don't scroll back when contracting an image if the image isn't partially visible. Close #859
This commit is contained in:
parent
763311f7dd
commit
363ea695d7
@ -5094,19 +5094,21 @@
|
||||
thumb = a.firstChild;
|
||||
if (thumb.hidden) {
|
||||
rect = a.getBoundingClientRect();
|
||||
if ($.engine === 'webkit') {
|
||||
if (rect.top < 0) {
|
||||
d.body.scrollTop += rect.top - 42;
|
||||
}
|
||||
if (rect.left < 0) {
|
||||
d.body.scrollLeft += rect.left;
|
||||
}
|
||||
} else {
|
||||
if (rect.top < 0) {
|
||||
d.documentElement.scrollTop += rect.top - 42;
|
||||
}
|
||||
if (rect.left < 0) {
|
||||
d.documentElement.scrollLeft += rect.left;
|
||||
if (rect.bottom > 0) {
|
||||
if ($.engine === 'webkit') {
|
||||
if (rect.top < 0) {
|
||||
d.body.scrollTop += rect.top - 42;
|
||||
}
|
||||
if (rect.left < 0) {
|
||||
d.body.scrollLeft += rect.left;
|
||||
}
|
||||
} else {
|
||||
if (rect.top < 0) {
|
||||
d.documentElement.scrollTop += rect.top - 42;
|
||||
}
|
||||
if (rect.left < 0) {
|
||||
d.documentElement.scrollLeft += rect.left;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ImageExpand.contract(thumb);
|
||||
|
||||
@ -4116,12 +4116,15 @@ ImageExpand =
|
||||
thumb = a.firstChild
|
||||
if thumb.hidden
|
||||
rect = a.getBoundingClientRect()
|
||||
if $.engine is 'webkit'
|
||||
d.body.scrollTop += rect.top - 42 if rect.top < 0
|
||||
d.body.scrollLeft += rect.left if rect.left < 0
|
||||
else
|
||||
d.documentElement.scrollTop += rect.top - 42 if rect.top < 0
|
||||
d.documentElement.scrollLeft += rect.left if rect.left < 0
|
||||
if rect.bottom > 0 # should be at least partially visible.
|
||||
# Scroll back to the thumbnail when contracting the image
|
||||
# to avoid being left miles away from the relevant post.
|
||||
if $.engine is 'webkit'
|
||||
d.body.scrollTop += rect.top - 42 if rect.top < 0
|
||||
d.body.scrollLeft += rect.left if rect.left < 0
|
||||
else
|
||||
d.documentElement.scrollTop += rect.top - 42 if rect.top < 0
|
||||
d.documentElement.scrollLeft += rect.left if rect.left < 0
|
||||
ImageExpand.contract thumb
|
||||
else
|
||||
ImageExpand.expand thumb
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user