Merge pull request #4007 from elemoine/bind

Do not use Function.prototype.bind in examples
This commit is contained in:
Éric Lemoine
2015-08-18 10:53:38 +02:00
2 changed files with 16 additions and 8 deletions

View File

@@ -33,10 +33,11 @@ Progress.prototype.addLoading = function() {
* Increment the count of loaded tiles.
*/
Progress.prototype.addLoaded = function() {
var this_ = this;
setTimeout(function() {
++this.loaded;
this.update();
}.bind(this), 100);
++this_.loaded;
this_.update();
}, 100);
};
@@ -49,7 +50,10 @@ Progress.prototype.update = function() {
if (this.loading === this.loaded) {
this.loading = 0;
this.loaded = 0;
setTimeout(this.hide.bind(this), 500);
var this_ = this;
setTimeout(function() {
this_.hide();
}, 500);
}
};

View File

@@ -33,10 +33,11 @@ Progress.prototype.addLoading = function() {
* Increment the count of loaded tiles.
*/
Progress.prototype.addLoaded = function() {
var this_ = this;
setTimeout(function() {
++this.loaded;
this.update();
}.bind(this), 100);
++this_.loaded;
this_.update();
}, 100);
};
@@ -49,7 +50,10 @@ Progress.prototype.update = function() {
if (this.loading === this.loaded) {
this.loading = 0;
this.loaded = 0;
setTimeout(this.hide.bind(this), 500);
var this_ = this;
setTimeout(function() {
this_.hide();
}, 500);
}
};