Simplify filtering plugin demo.

This commit is contained in:
Aiosa 2024-08-24 09:59:18 +02:00
parent 29b01cf1bd
commit 63180a1589
2 changed files with 6 additions and 21 deletions

View File

@ -321,7 +321,6 @@ $.extend( $.World.prototype, $.EventSource.prototype, /** @lends OpenSeadragon.W
}); });
$.Promise.all(tileList.map(tile => { $.Promise.all(tileList.map(tile => {
tile.AAAAAAA = new Date().toISOString();
if (restoreTiles) { if (restoreTiles) {
tile.restore(); tile.restore();
} }

View File

@ -54,8 +54,8 @@
const self = this; const self = this;
this.viewer = options.viewer; this.viewer = options.viewer;
this.viewer.addHandler('tile-loaded', tileLoadedHandler); this.viewer.addHandler('tile-loaded', applyFilters);
this.viewer.addHandler('tile-invalidated', tileUpdateHandler); this.viewer.addHandler('tile-invalidated', applyFilters);
// filterIncrement allows to determine whether a tile contains the // filterIncrement allows to determine whether a tile contains the
// latest filters results. // latest filters results.
@ -63,26 +63,12 @@
setOptions(this, options); setOptions(this, options);
async function tileLoadedHandler(event) { async function applyFilters(e) {
await applyFilters(event.tile, event.tiledImage); const tile = e.tile,
} tiledImage = e.tiledImage,
processors = getFiltersProcessors(self, 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);
if (processors.length === 0) { if (processors.length === 0) {
tile._filterIncrement = self.filterIncrement;
return; return;
} }