From 63180a1589d1d59e6379b1368ab49aa493aa41fb Mon Sep 17 00:00:00 2001 From: Aiosa <469130@mail.muni.cz> Date: Sat, 24 Aug 2024 09:59:18 +0200 Subject: [PATCH] Simplify filtering plugin demo. --- src/world.js | 1 - test/demo/filtering-plugin/plugin.js | 26 ++++++-------------------- 2 files changed, 6 insertions(+), 21 deletions(-) diff --git a/src/world.js b/src/world.js index 91fdec4c..1b346456 100644 --- a/src/world.js +++ b/src/world.js @@ -321,7 +321,6 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W }); $.Promise.all(tileList.map(tile => { - tile.AAAAAAA = new Date().toISOString(); if (restoreTiles) { tile.restore(); } diff --git a/test/demo/filtering-plugin/plugin.js b/test/demo/filtering-plugin/plugin.js index 3885bcea..4505b282 100644 --- a/test/demo/filtering-plugin/plugin.js +++ b/test/demo/filtering-plugin/plugin.js @@ -54,8 +54,8 @@ const self = this; this.viewer = options.viewer; - this.viewer.addHandler('tile-loaded', tileLoadedHandler); - this.viewer.addHandler('tile-invalidated', tileUpdateHandler); + this.viewer.addHandler('tile-loaded', applyFilters); + this.viewer.addHandler('tile-invalidated', applyFilters); // filterIncrement allows to determine whether a tile contains the // latest filters results. @@ -63,26 +63,12 @@ setOptions(this, options); - async function tileLoadedHandler(event) { - await applyFilters(event.tile, event.tiledImage); - } - - function tileUpdateHandler(event) { - const tile = event.tile; - const incrementCount = tile._filterIncrement; - if (incrementCount === self.filterIncrement) { - //we _know_ we have up-to-date data to render - return; - } - //go async otherwise - return applyFilters(tile, event.tiledImage); - } - - async function applyFilters(tile, tiledImage) { - const processors = getFiltersProcessors(self, tiledImage); + async function applyFilters(e) { + const tile = e.tile, + tiledImage = e.tiledImage, + processors = getFiltersProcessors(self, tiledImage); if (processors.length === 0) { - tile._filterIncrement = self.filterIncrement; return; }