Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix hover #78

Merged
merged 1 commit into from
Aug 12, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading