From fefc39147c3da4ded5508a4891685868dfdf7f43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Lemoine?= Date: Tue, 18 Aug 2015 09:47:13 +0200 Subject: [PATCH] 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. --- examples/image-load-events.js | 12 ++++++++---- examples/tile-load-events.js | 12 ++++++++---- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/examples/image-load-events.js b/examples/image-load-events.js index 293810f89f..885556aff3 100644 --- a/examples/image-load-events.js +++ b/examples/image-load-events.js @@ -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); } }; diff --git a/examples/tile-load-events.js b/examples/tile-load-events.js index df10f4575e..b6610b0327 100644 --- a/examples/tile-load-events.js +++ b/examples/tile-load-events.js @@ -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); } };