Skip to content

Commit

Permalink
Merge pull request #78 from brauliorivas/fix/hover
Browse files Browse the repository at this point in the history
Fix hover
  • Loading branch information
kjvbrt authored Aug 12, 2024
2 parents 57d2787 + df44b9b commit c46073f
Showing 1 changed file with 23 additions and 18 deletions.
41 changes: 23 additions & 18 deletions js/draw/box.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,29 +92,34 @@ export function buildBox(object) {
}

export function addHoverModal(box, lines) {
let objectModal = null;
const objectModal = createObjectModal(lines, box.width);
const objectModalWidth = parseInt(objectModal.width);
const boxWidth = parseInt(box.width);

let showModal = false;

const clean = () => {
showModal = false;
removeObjectModal(objectModal);
};

box.on("pointerover", () => {
objectModal = createObjectModal(lines, box.width);
const objectModalWidth = parseInt(objectModal.width);
const boxWidth = parseInt(box.width);
const x = parseInt(box.position.x);
const xPosition = (boxWidth - objectModalWidth) / 2 + x;
const y = box.position.y;

const timeout = setTimeout(() => {
if (showModal) {
return;
}
showModal = true;
setTimeout(() => {
if (!showModal) {
return;
}
const x = parseInt(box.position.x);
const xPosition = (boxWidth - objectModalWidth) / 2 + x;
const y = box.position.y;
renderObjectModal(objectModal, xPosition, y);
}, 500);

const clean = () => {
clearTimeout(timeout);
removeObjectModal(objectModal);
objectModal = null;
};

box.on("pointerdown", clean);
box.on("pointerout", clean);
});
box.on("pointerdown", clean);
box.on("pointerout", clean);
}

export function addTitleToBox(title, box) {
Expand Down

0 comments on commit c46073f

Please sign in to comment.