WebUI: Use native css transition for context menu

Reduce MooTools usage.

PR #23069.
This commit is contained in:
tehcneko 2025-08-11 16:28:47 +08:00 committed by GitHub
commit f743ae2d08
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 12 additions and 12 deletions

View file

@ -323,7 +323,17 @@ a.propButton img {
background-color: var(--color-background-default);
border: 1px solid var(--color-border-default);
display: none;
opacity: 0;
padding: 0;
transition:
opacity 0.2s ease-in-out,
visibility 0.2s ease-in-out;
visibility: hidden;
}
.contextMenu.visible {
opacity: 1;
visibility: visible;
}
.contextMenu .separator {

View file

@ -60,7 +60,6 @@ window.qBittorrent.ContextMenu ??= (() => {
onShow: () => {},
onHide: () => {},
onClick: () => {},
fadeSpeed: 200,
touchTimer: 600,
...options
};
@ -68,15 +67,6 @@ window.qBittorrent.ContextMenu ??= (() => {
// option diffs menu
this.menu = document.getElementById(this.options.menu);
// fx
this.fx = new Fx.Tween(this.menu, {
property: "opacity",
duration: this.options.fadeSpeed,
onComplete: () => {
this.menu.style.visibility = (getComputedStyle(this.menu).opacity > 0) ? "visible" : "hidden";
}
});
// hide and begin the listener
this.hide().startListener();
@ -231,7 +221,7 @@ window.qBittorrent.ContextMenu ??= (() => {
show(trigger) {
if (lastShownContextMenu && (lastShownContextMenu !== this))
lastShownContextMenu.hide();
this.fx.start(1);
this.menu.classList.add("visible");
this.options.onShow.call(this);
lastShownContextMenu = this;
return this;
@ -240,7 +230,7 @@ window.qBittorrent.ContextMenu ??= (() => {
// hide the menu
hide(trigger) {
if (lastShownContextMenu && (lastShownContextMenu.menu.style.visibility !== "hidden")) {
this.fx.start(0);
this.menu.classList.remove("visible");
this.options.onHide.call(this);
}
return this;