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 15, 2023
1 parent 20d663c commit 91326a3
Showing 1 changed file with 21 additions and 9 deletions.
30 changes: 21 additions & 9 deletions src/interaction/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -447,16 +447,28 @@ 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 () {
let originCursor;

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

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

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

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

0 comments on commit 91326a3

Please sign in to comment.