Skip to content

Commit

Permalink
fix: restore to last cursor not default
Browse files Browse the repository at this point in the history
  • Loading branch information
Deathsteps committed Sep 18, 2023
1 parent 20d663c commit 4c85940
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/interaction/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,26 @@ export function renderBackground({
return [append, remove, is] as const;
}

export function setCursor(root, cursor) {
// @ts-ignore
const canvas = root.getRootNode().defaultView;
const dom = canvas.getContextService().getDomElement();
if (dom?.style) dom.style.cursor = cursor;
}
export const { setCursor, restoreCursor } = (function () {
function setCursor(root, cursor) {
// @ts-ignore
const canvas = root.getRootNode().defaultView;
const dom = canvas.getContextService().getDomElement();
if (dom?.style) {
root.cursor = dom.style.cursor;
dom.style.cursor = cursor;
}
}

export function restoreCursor(root) {
setCursor(root, 'default');
}
function restoreCursor(root) {
setCursor(root, root.cursor);
}

return {
setCursor,
restoreCursor,
};
})();

export function selectElementByData(elements, data, datum) {
return elements.find((d) =>
Expand Down

0 comments on commit 4c85940

Please sign in to comment.