From cfd2693fc7636499fafb0799b9e3a9b1b1a5fe74 Mon Sep 17 00:00:00 2001
From: Martin Pluta <martin.pluta@martinpluta.eu>
Date: Fri, 20 Feb 2015 21:12:34 +0100
Subject: [PATCH] added destroy and clear methods to resolve tile caching issue

---
 src/viewer.js | 3 ++-
 src/world.js  | 2 ++
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/viewer.js b/src/viewer.js
index 307a1500..a75c4ab1 100644
--- a/src/viewer.js
+++ b/src/viewer.js
@@ -673,7 +673,8 @@ $.extend( $.Viewer.prototype, $.EventSource.prototype, $.ControlDock.prototype,
 
         THIS[ this.hash ].animating = false;
         this.world.removeAll();
-
+        this.imageLoader.clear();
+        
         /**
          * Raised when the viewer is closed (see {@link OpenSeadragon.Viewer#close}).
          *
diff --git a/src/world.js b/src/world.js
index 4b1c9826..c9e65225 100644
--- a/src/world.js
+++ b/src/world.js
@@ -183,6 +183,7 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W
         }
 
         item.removeHandler('bounds-change', this._delegatedFigureSizes);
+        item.destroy();
         this._items.splice( index, 1 );
         this._figureSizes();
         this._needsDraw = true;
@@ -199,6 +200,7 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W
         for (var i = 0; i < this._items.length; i++) {
             item = this._items[i];
             item.removeHandler('bounds-change', this._delegatedFigureSizes);
+            item.destroy();
         }
 
         var removedItems = this._items;