|
|
@ -25,44 +25,45 @@ window.addEventListener('DOMContentLoaded', (event) => { |
|
|
|
return top >= 38 && bottom <= height; |
|
|
|
return top >= 38 && bottom <= height; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const setFloatPos = (float, xpos, ypos) => { |
|
|
|
const setFloatPos = (quote, float, xpos, ypos) => { |
|
|
|
|
|
|
|
const quotepos = quote.getBoundingClientRect(); |
|
|
|
const post = float.firstChild; |
|
|
|
const post = float.firstChild; |
|
|
|
const iw = document.body.offsetWidth-10; |
|
|
|
const iw = document.body.offsetWidth-10; |
|
|
|
const ih = window.innerHeight; |
|
|
|
const ih = window.innerHeight; |
|
|
|
const left = xpos < iw/2; |
|
|
|
const left = xpos < iw/2; |
|
|
|
if (left) { |
|
|
|
if (left) { |
|
|
|
float.style.left = `${xpos+10}px`; |
|
|
|
float.style.left = `${quotepos.right+10}px`; |
|
|
|
if (xpos+post.offsetWidth >= iw) { |
|
|
|
if (quotepos.right+10+post.offsetWidth >= iw) { |
|
|
|
float.style.right = '5px'; |
|
|
|
float.style.right = '5px'; |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
float.style.right = `${iw-xpos+10}px`; |
|
|
|
float.style.right = `${iw-quotepos.left}px`; |
|
|
|
if (xpos-post.offsetWidth <= 0) { |
|
|
|
if (quotepos.left-post.offsetWidth <= 0) { |
|
|
|
float.style.left = '5px'; |
|
|
|
float.style.left = '5px'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
const top = ypos < ih/2; |
|
|
|
const top = ypos < ih/2; |
|
|
|
if (top && ypos+post.offsetHeight < ih) { |
|
|
|
if (top && quotepos.bottom+post.offsetHeight < ih) { |
|
|
|
float.style.top = `${ypos+10}px`; |
|
|
|
float.style.top = `${quotepos.top}px`; |
|
|
|
} else if (!top && post.offsetHeight < ypos) { |
|
|
|
} else if (!top && post.offsetHeight < ypos) { |
|
|
|
float.style.top = `${ypos-post.offsetHeight-10}px`; |
|
|
|
float.style.top = `${quotepos.bottom-post.offsetHeight}px`; |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
float.style.top = '42px'; |
|
|
|
float.style.top = '42px'; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const floatPost = (post, xpos, ypos) => { |
|
|
|
const floatPost = (quote, post, xpos, ypos) => { |
|
|
|
const clone = document.createElement('div'); |
|
|
|
const clone = document.createElement('div'); |
|
|
|
clone.id = 'float'; |
|
|
|
clone.id = 'float'; |
|
|
|
clone.appendChild(post.cloneNode(true)); |
|
|
|
clone.appendChild(post.cloneNode(true)); |
|
|
|
document.body.appendChild(clone); |
|
|
|
document.body.appendChild(clone); |
|
|
|
setFloatPos(clone, xpos, ypos); |
|
|
|
setFloatPos(quote, clone, xpos, ypos); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const moveHighlightPost = (e) => { |
|
|
|
const moveHighlightPost = function (e) { |
|
|
|
const float = document.getElementById('float'); |
|
|
|
const float = document.getElementById('float'); |
|
|
|
if (float != null) { |
|
|
|
if (float != null) { |
|
|
|
setFloatPos(float, e.clientX, e.clientY); |
|
|
|
setFloatPos(this, float, e.clientX, e.clientY); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -124,7 +125,6 @@ window.addEventListener('DOMContentLoaded', (event) => { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
if (lastHover !== loading) { |
|
|
|
if (lastHover !== loading) { |
|
|
|
// if (!hovering && lastHover !== loading) {
|
|
|
|
|
|
|
|
return; //dont show for ones not hovering
|
|
|
|
return; //dont show for ones not hovering
|
|
|
|
} |
|
|
|
} |
|
|
|
if (threadJson.postId == hash) { |
|
|
|
if (threadJson.postId == hash) { |
|
|
@ -154,7 +154,7 @@ window.addEventListener('DOMContentLoaded', (event) => { |
|
|
|
if (anchor && isVisible(hoveredPost)) { |
|
|
|
if (anchor && isVisible(hoveredPost)) { |
|
|
|
hovering ? hoveredPost.classList.add('highlighted') : hoveredPost.classList.remove('highlighted'); |
|
|
|
hovering ? hoveredPost.classList.add('highlighted') : hoveredPost.classList.remove('highlighted'); |
|
|
|
} else if (hovering) { |
|
|
|
} else if (hovering) { |
|
|
|
floatPost(hoveredPost, e.clientX, e.clientY); |
|
|
|
floatPost(this, hoveredPost, e.clientX, e.clientY); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|