Skip to content

Commit

Permalink
🐛 fix(Safari): Compatible with lower versions of Safari
Browse files Browse the repository at this point in the history
  • Loading branch information
capdiem committed Apr 11, 2023
1 parent a163650 commit 8b33224
Showing 1 changed file with 16 additions and 17 deletions.
33 changes: 16 additions & 17 deletions src/Component/BlazorComponent/wwwroot/js/delayable.js
Original file line number Diff line number Diff line change
@@ -1,36 +1,35 @@
class Delayable {
#dotNetHelper = {};

#openDelay = 0;
#closeDelay = 0;
#openTimeout;
#closeTimeout;
dotNetHelper;
openDelay;
closeDelay;
openTimeout;
closeTimeout;

constructor(dotNet, openDelay, closeDelay) {
this.#dotNetHelper = dotNet;
this.#openDelay = openDelay;
this.#closeDelay = closeDelay;
this.dotNetHelper = dotNet;
this.openDelay = openDelay;
this.closeDelay = closeDelay;
}

clearDelay() {
clearTimeout(this.#openTimeout);
clearTimeout(this.#closeTimeout);
clearTimeout(this.openTimeout);
clearTimeout(this.closeTimeout);
}

runDelay(type, cb) {
this.clearDelay();

if (type === "open") {
const delay = parseInt(this.#openDelay, 10);
const delay = parseInt(this.openDelay, 10);

this.#openTimeout = setTimeout(cb || (() => {
this.#dotNetHelper.invokeMethodAsync('SetActive', true);
this.openTimeout = setTimeout(cb || (() => {
this.dotNetHelper.invokeMethodAsync('SetActive', true);
}), delay)
} else {
const delay = parseInt(this.#closeDelay, 10);
const delay = parseInt(this.closeDelay, 10);

this.#closeTimeout = setTimeout(cb || (() => {
this.#dotNetHelper.invokeMethodAsync('SetActive', false);
this.closeTimeout = setTimeout(cb || (() => {
this.dotNetHelper.invokeMethodAsync('SetActive', false);
}), delay)
}
}
Expand Down

0 comments on commit 8b33224

Please sign in to comment.