mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-24 22:26:10 +03:00
Update demo plugins to the new api design
This commit is contained in:
parent
541fe2e4df
commit
e24f7d1358
@ -49,10 +49,6 @@
|
||||
this.viewer = options.viewer;
|
||||
this.viewer.addHandler('tile-invalidated', applyFilters);
|
||||
|
||||
// filterIncrement allows to determine whether a tile contains the
|
||||
// latest filters results.
|
||||
this.filterIncrement = 0;
|
||||
|
||||
setOptions(this, options);
|
||||
|
||||
async function applyFilters(e) {
|
||||
@ -66,23 +62,12 @@
|
||||
const contextCopy = await e.getData('context2d');
|
||||
if (!contextCopy) return;
|
||||
|
||||
if (contextCopy.canvas.width === 0) {
|
||||
debugger;
|
||||
}
|
||||
|
||||
try {
|
||||
const currentIncrement = self.filterIncrement;
|
||||
for (let i = 0; i < processors.length; i++) {
|
||||
if (self.filterIncrement !== currentIncrement) {
|
||||
break;
|
||||
}
|
||||
await processors[i](contextCopy);
|
||||
}
|
||||
|
||||
await e.setData(contextCopy, 'context2d');
|
||||
} catch (e) {
|
||||
// pass, this is error caused by canvas being destroyed & replaced
|
||||
for (let i = 0; i < processors.length; i++) {
|
||||
if (e.outdated()) return;
|
||||
await processors[i](contextCopy);
|
||||
}
|
||||
if (e.outdated()) return;
|
||||
await e.setData(contextCopy, 'context2d');
|
||||
}
|
||||
};
|
||||
|
||||
@ -99,7 +84,6 @@
|
||||
filter.processors = $.isArray(filter.processors) ?
|
||||
filter.processors : [filter.processors];
|
||||
}
|
||||
instance.filterIncrement++;
|
||||
instance.viewer.requestInvalidate();
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ window.pluginB = async function(e) {
|
||||
const canvas = ctx.canvas;
|
||||
ctx.fillStyle = "rgba(156, 0, 26, 0.4)";
|
||||
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
||||
await tile.setData(ctx, 'context2d');
|
||||
await e.setData(ctx, 'context2d');
|
||||
}
|
||||
};
|
||||
// higher number = earlier execution
|
||||
|
Loading…
Reference in New Issue
Block a user