add front-comments
This commit is contained in:
parent
c3ea78cab5
commit
c9f4af7e58
53 changed files with 2921 additions and 1 deletions
30
site/plugins/front-comments/src/front/composables/helpers.js
Normal file
30
site/plugins/front-comments/src/front/composables/helpers.js
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
class Helpers {
|
||||
static fixOffscreen(node) {
|
||||
const margin = 16;
|
||||
|
||||
if (!node) {
|
||||
console.error("fixOffscreen: node does not exist");
|
||||
return;
|
||||
}
|
||||
|
||||
const XDiff =
|
||||
window.innerWidth +
|
||||
window.pageXOffset -
|
||||
(node.offsetLeft + node.offsetWidth + window.pageXOffset);
|
||||
|
||||
const YDiff =
|
||||
window.innerHeight +
|
||||
window.pageYOffset -
|
||||
(node.offsetTop + node.offsetHeight);
|
||||
|
||||
if (XDiff <= 0) {
|
||||
node.style.transform = `translateX(${XDiff - margin}px)`;
|
||||
}
|
||||
|
||||
if (YDiff <= 0) {
|
||||
node.style.transform += `translateY(${YDiff - margin}px)`;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default Helpers;
|
||||
Loading…
Add table
Add a link
Reference in a new issue