diff --git a/src/tiledimage.js b/src/tiledimage.js
index 525c3eea..41c971ab 100644
--- a/src/tiledimage.js
+++ b/src/tiledimage.js
@@ -1826,7 +1826,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag
if ( tile.loading ) {
// the tile is already in the download queue
this._tilesLoading++;
- } else if (!tile.loaded && !loadingCoverage) {
+ } else if (!loadingCoverage) {
// add tile to best tiles to load only when not loaded already
best = this._compareTiles( best, tile, this.maxTilesPerFrame );
}
diff --git a/test/demo/filtering-plugin/demo.js b/test/demo/filtering-plugin/demo.js
index ec49a1cc..f53e50e9 100644
--- a/test/demo/filtering-plugin/demo.js
+++ b/test/demo/filtering-plugin/demo.js
@@ -127,13 +127,20 @@ class SpinnerSlider {
}
+const switcher = new DrawerSwitcher();
+switcher.addDrawerOption("drawer");
+$("#title-drawer").html(switcher.activeName("drawer"));
+switcher.render("#title-banner");
+
const viewer = window.viewer = new OpenSeadragon({
id: 'openseadragon',
prefixUrl: '/build/openseadragon/images/',
tileSources: 'https://openseadragon.github.io/example-images/highsmith/highsmith.dzi',
- crossOriginPolicy: 'Anonymous'
+ crossOriginPolicy: 'Anonymous',
+ drawer: switcher.activeImplementation("drawer"),
});
+
// Prevent Caman from caching the canvas because without this:
// 1. We have a memory leak
// 2. Non-caman filters in between 2 camans filters get ignored.
diff --git a/test/demo/filtering-plugin/index.html b/test/demo/filtering-plugin/index.html
index 96798ec2..88f75f5c 100644
--- a/test/demo/filtering-plugin/index.html
+++ b/test/demo/filtering-plugin/index.html
@@ -27,13 +27,14 @@
+
-
- OpenSeadragon filtering plugin demo.
+
+ OpenSeadragon filtering plugin demo:
You might want to check the plugin repository to see if the plugin code is up to date.
diff --git a/test/helpers/drawer-switcher.js b/test/helpers/drawer-switcher.js
new file mode 100644
index 00000000..6913c0eb
--- /dev/null
+++ b/test/helpers/drawer-switcher.js
@@ -0,0 +1,76 @@
+/**
+ * Ability to switch between different drawers.
+ * Usage: with two viewers, we would do
+ *
+ * const switcher = new DrawerSwitcher();
+ * switcher.addDrawerOption("drawer_left", "Select drawer for the left viewer", "canvas");
+ * switcher.addDrawerOption("drawer_right", "Select drawer for the right viewer", "webgl");
+ * const viewer1 = window.viewer1 = new OpenSeadragon({
+ * id: 'openseadragon',
+ * ...
+ * drawer:switcher.activeImplementation("drawer_left"),
+ * });
+ * $("#my-title-for-left-drawer").html(`Viewer using drawer ${switcher.activeName("drawer_left")}`);
+ * $("#container").html(switcher.render());
+ * // OR switcher.render("#container")
+ * // ..do the same for the second viewer
+ */
+class DrawerSwitcher {
+ url = new URL(window.location.href);
+ drawers = {
+ canvas: "Context2d drawer (default in OSD <= 4.1.0)",
+ webgl: "New WebGL drawer"
+ };
+ _data = {}
+
+ addDrawerOption(urlQueryName, title="Select drawer:", defaultDrawerImplementation="canvas") {
+ const drawer = this.url.searchParams.get(urlQueryName) || defaultDrawerImplementation;
+ if (!this.drawers[drawer]) throw "Unsupported drawer implementation: " + drawer;
+
+ let context = this._data[urlQueryName] = {
+ query: urlQueryName,
+ implementation: drawer,
+ title: title
+ };
+ }
+
+ activeName(urlQueryName) {
+ return this.drawers[this.activeImplementation(urlQueryName)];
+ }
+
+ activeImplementation(urlQueryName) {
+ return this._data[urlQueryName].implementation;
+ }
+
+ _getFormData(useNewline=true) {
+ return Object.values(this._data).map(ctx => `${ctx.title}
+`).join(useNewline ? "
" : "");
+ }
+
+ _preserveOtherSeachParams() {
+ let res = [], registered = Object.keys(this._data);
+ for (let [k, v] of this.url.searchParams.entries()) {
+ if (!registered.includes(k)) {
+ res.push(``);
+ }
+ }
+ return res.join('\n');
+ }
+
+ render(selector, useNewline=undefined) {
+ useNewline = typeof useNewline === "boolean" ? useNewline : Object.keys(this._data).length > 1;
+ const html = `
+
+
`;
+ if (selector) $(selector).append(html);
+ return html;
+ }
+}