hgdf
This commit is contained in:
@@ -1062,10 +1062,6 @@ class CommentSystem {
|
||||
preview.style.position = 'fixed';
|
||||
preview.style.zIndex = (100000 + level).toString();
|
||||
|
||||
// Try to place it to the right of the link, or top/bottom if needed
|
||||
let left = rect.right + 10;
|
||||
let top = rect.top;
|
||||
|
||||
document.body.appendChild(preview);
|
||||
CommentSystem.playEmojiVideos(preview);
|
||||
|
||||
@@ -1090,16 +1086,28 @@ class CommentSystem {
|
||||
|
||||
const previewRect = preview.getBoundingClientRect();
|
||||
|
||||
// Boundary checks
|
||||
if (left + previewRect.width > window.innerWidth) {
|
||||
// Default: position preview to the right of the link
|
||||
let left = rect.right + 10;
|
||||
let top = rect.top;
|
||||
|
||||
// If there's NOT enough space on the right, open to the left
|
||||
if (left + previewRect.width > window.innerWidth - 10) {
|
||||
left = rect.left - previewRect.width - 10;
|
||||
}
|
||||
if (left < 0) left = 10;
|
||||
|
||||
if (top + previewRect.height > window.innerHeight) {
|
||||
// Clamp to screen boundaries if left/right are both tight
|
||||
if (left < 10) {
|
||||
left = 10;
|
||||
}
|
||||
if (left + previewRect.width > window.innerWidth - 10) {
|
||||
left = Math.max(10, window.innerWidth - previewRect.width - 10);
|
||||
}
|
||||
|
||||
// Clamp top & bottom boundary
|
||||
if (top + previewRect.height > window.innerHeight - 10) {
|
||||
top = window.innerHeight - previewRect.height - 10;
|
||||
}
|
||||
if (top < 0) top = 10;
|
||||
if (top < 10) top = 10;
|
||||
|
||||
preview.style.left = left + 'px';
|
||||
preview.style.top = top + 'px';
|
||||
|
||||
Reference in New Issue
Block a user