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