Browse Source

fixes onend() (#358)

* fixes onend()

* Update speedtest.js
Niels Peen 5 years ago
parent
commit
5cef820749
1 changed files with 2 additions and 2 deletions
  1. 2 2
      speedtest.js

+ 2 - 2
speedtest.js

@@ -330,13 +330,13 @@ Speedtest.prototype = {
         console.error("Speedtest onupdate event threw exception: " + e);
       }
       if (data.testState >= 4) {
+	  clearInterval(this.updater);
+        this._state = 4;
         try {
           if (this.onend) this.onend(data.testState == 5);
         } catch (e) {
           console.error("Speedtest onend event threw exception: " + e);
         }
-        clearInterval(this.updater);
-        this._state = 4;
       }
     }.bind(this);
     this.updater = setInterval(