Skip to content

Commit

Permalink
fix hover, modal dissapears and won't stay as expected
Browse files Browse the repository at this point in the history
  • Loading branch information
brauliorivas committed Aug 10, 2024
1 parent 4ba0b9b commit df44b9b
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 df44b9b

Please sign in to comment.