mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-23 05:36:09 +03:00
Simplify filtering plugin demo.
This commit is contained in:
parent
29b01cf1bd
commit
63180a1589
@ -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();
|
||||||
}
|
}
|
||||||
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user