Skip to content

Commit

Permalink
Context Menu Tweaks
Browse files Browse the repository at this point in the history
- Adjust transform origin such that animation plays from cursor even when bounds are met
  • Loading branch information
sandervonk committed Sep 1, 2022
1 parent fd84f12 commit b06a801
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions js/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,7 @@ class ContextMenu {
this.menuItems = this.menuItems.concat(result);
}
}
this.x = e.clientX;
this.y = e.clientY;
[this.x, this.y] = [e.clientX, e.clientY];
this.build(this.x, this.y);
}
makeMenuItem(item) {
Expand Down Expand Up @@ -181,6 +180,7 @@ class ContextMenu {
this.menu.css({
top: Math.max(this.windowPadding, Math.min(y, $(window).height() - this.menu.outerHeight() - this.windowPadding)),
left: Math.max(this.windowPadding, Math.min(x, $(window).width() - this.menu.outerWidth() - this.windowPadding)),
"transform-origin": `${this.x - Math.max(this.windowPadding, Math.min(x, $(window).width() - this.menu.outerWidth() - this.windowPadding))}px ${this.y - Math.max(this.windowPadding, Math.min(y, $(window).height() - this.menu.outerHeight() - this.windowPadding))}px`,
});
if ($("#cm-page-items:empty").length) {
$(".context-menu").css("height", "fit-content");
Expand Down

0 comments on commit b06a801

Please sign in to comment.