X-Git-Url: http://git.osdn.net/view?a=blobdiff_plain;f=js%2Ftheme.js;h=f878f6170c6579f1aece0055209234c3bb112bc8;hb=b64c521758e95ccbfaaa2c9125ae8ef91d3b9bec;hp=dd0cb2c6e6eccd9b11ec25583685d5dd8a1219d4;hpb=afc9162221f5e5b7fdd594c1e105b915e657622f;p=alterlinux%2Flightdm-webkit2-theme-alter.git diff --git a/js/theme.js b/js/theme.js index dd0cb2c..f878f61 100644 --- a/js/theme.js +++ b/js/theme.js @@ -271,7 +271,7 @@ class SplashScreen { /******************** Event Listeners ********************/ this.clock = setInterval(() => { $(this).trigger("tick"); - log.error("tick"); + if (!this.isActive()) $(this).trigger("inactive"); }, 500); @@ -319,35 +319,42 @@ class SplashScreen { * adds a resetTimeout function to automatically close after a period of user * inactivity */ close(time=450) { - if (!this.is_open) - return + if (this.state == "closed" || this.state == "moving") { + log.warn("Cannot close splash screen when state is: " + this.state); + return; + } + + this.state = "moving"; this.$el.animate({ top: "0" }, time, "easeInCubic", () => { - this.is_open = false + this.state = "closed"; clearTimeout(this.resetTimeout); }); } open(time=400) { + if (this.state == "open" || this.state == "moving") { + log.warn("Cannot open splash screen when state is: " + this.state); + return; + } clearTimeout(this.resetTimeout); let reset_duration = 60*1000; - - if (this.is_open) { + if (this.state == "open" || this.state == "moving") { this.resetTimeout = setTimeout(this.reset, reset_duration); return; } + this.state = "moving"; this.$el.animate({ top: "-100%" }, time, "easeInCubic", () => { - this.is_open = true; + this.state = "open"; // close the screen after 1 minute of inactivty this.resetTimeout = setTimeout(() => this.reset, reset_duration); }); } reset() { - if (this.is_open == true) { - + if (this.state == "open") { this.close(); $(this).trigger("timeout"); } @@ -363,8 +370,8 @@ class SplashScreen { this.open(); break; case 27: - if (this.is_open) this.close(); - else this.open(); + if (this.state == "open") this.close(); + else if (this.state == "closed") this.open(); break; default: if (e.keyCode != 82 && e.keyCode != 17) // for testing @@ -373,7 +380,7 @@ class SplashScreen { } // stop reset timeout since there has been user activity - if (this.is_open) + if (this.state == "open") clearTimeout(this.resetTimeout); if (!this.isActive())