Do not use Function.prototype.bind in examples

PhantomJS 1.x does not have Function.prototype.bind, so do not use that function in examples.
This commit is contained in:
Éric Lemoine
2015-08-18 09:47:13 +02:00
parent d204d7764a
commit fefc39147c
2 changed files with 16 additions and 8 deletions
+8 -4
View File
@@ -33,10 +33,11 @@ Progress.prototype.addLoading = function() {
* Increment the count of loaded tiles. * Increment the count of loaded tiles.
*/ */
Progress.prototype.addLoaded = function() { Progress.prototype.addLoaded = function() {
var this_ = this;
setTimeout(function() { setTimeout(function() {
++this.loaded; ++this_.loaded;
this.update(); this_.update();
}.bind(this), 100); }, 100);
}; };
@@ -49,7 +50,10 @@ Progress.prototype.update = function() {
if (this.loading === this.loaded) { if (this.loading === this.loaded) {
this.loading = 0; this.loading = 0;
this.loaded = 0; this.loaded = 0;
setTimeout(this.hide.bind(this), 500); var this_ = this;
setTimeout(function() {
this_.hide();
}, 500);
} }
}; };
+8 -4
View File
@@ -33,10 +33,11 @@ Progress.prototype.addLoading = function() {
* Increment the count of loaded tiles. * Increment the count of loaded tiles.
*/ */
Progress.prototype.addLoaded = function() { Progress.prototype.addLoaded = function() {
var this_ = this;
setTimeout(function() { setTimeout(function() {
++this.loaded; ++this_.loaded;
this.update(); this_.update();
}.bind(this), 100); }, 100);
}; };
@@ -49,7 +50,10 @@ Progress.prototype.update = function() {
if (this.loading === this.loaded) { if (this.loading === this.loaded) {
this.loading = 0; this.loading = 0;
this.loaded = 0; this.loaded = 0;
setTimeout(this.hide.bind(this), 500); var this_ = this;
setTimeout(function() {
this_.hide();
}, 500);
} }
}; };