mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-25 06:36:11 +03:00
Fix IndexSizeError on IE and Edge #1033
Internet Explorer and Microsoft Edge throw IndexSizeError when you call context.drawImage with negative x or y or width or height greater than the canvas width or height respectively.
This commit is contained in:
parent
254b426b2b
commit
c24e8ceedf
@ -423,6 +423,24 @@ $.Drawer.prototype = {
|
|||||||
this.context.globalCompositeOperation = compositeOperation;
|
this.context.globalCompositeOperation = compositeOperation;
|
||||||
}
|
}
|
||||||
if (bounds) {
|
if (bounds) {
|
||||||
|
// Internet Explorer and Microsoft Edge throw IndexSizeError
|
||||||
|
// when you call context.drawImage with negative x or y
|
||||||
|
// or width or height greater than the canvas width or height respectively
|
||||||
|
if (bounds.x < 0) {
|
||||||
|
bounds.width += bounds.x;
|
||||||
|
bounds.x = 0;
|
||||||
|
}
|
||||||
|
if (bounds.width > this.sketchCanvas.width) {
|
||||||
|
bounds.width = this.sketchCanvas.width;
|
||||||
|
}
|
||||||
|
if (bounds.y < 0) {
|
||||||
|
bounds.height += bounds.y;
|
||||||
|
bounds.y = 0;
|
||||||
|
}
|
||||||
|
if (bounds.height > this.sketchCanvas.height) {
|
||||||
|
bounds.height = this.sketchCanvas.height;
|
||||||
|
}
|
||||||
|
|
||||||
this.context.drawImage(
|
this.context.drawImage(
|
||||||
this.sketchCanvas,
|
this.sketchCanvas,
|
||||||
bounds.x,
|
bounds.x,
|
||||||
|
Loading…
Reference in New Issue
Block a user