mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 05:06:09 +03:00
Merge pull request #1102 from avandecreme/sketch_canvas_size
Fix sketch canvas not resizing properly. Fix #973
This commit is contained in:
commit
855bfbe168
@ -328,7 +328,11 @@ $.Drawer.prototype = {
|
|||||||
// the viewport get rotated later on, we will need to resize it.
|
// the viewport get rotated later on, we will need to resize it.
|
||||||
if (this.viewport.getRotation() === 0) {
|
if (this.viewport.getRotation() === 0) {
|
||||||
var self = this;
|
var self = this;
|
||||||
this.viewer.addOnceHandler('rotate', function resizeSketchCanvas() {
|
this.viewer.addHandler('rotate', function resizeSketchCanvas() {
|
||||||
|
if (self.viewport.getRotation() === 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.viewer.removeHandler('rotate', resizeSketchCanvas);
|
||||||
var sketchCanvasSize = self._calculateSketchCanvasSize();
|
var sketchCanvasSize = self._calculateSketchCanvasSize();
|
||||||
self.sketchCanvas.width = sketchCanvasSize.x;
|
self.sketchCanvas.width = sketchCanvasSize.x;
|
||||||
self.sketchCanvas.height = sketchCanvasSize.y;
|
self.sketchCanvas.height = sketchCanvasSize.y;
|
||||||
@ -422,8 +426,8 @@ $.Drawer.prototype = {
|
|||||||
this.context.globalCompositeOperation = compositeOperation;
|
this.context.globalCompositeOperation = compositeOperation;
|
||||||
}
|
}
|
||||||
if (bounds) {
|
if (bounds) {
|
||||||
// Internet Explorer and Microsoft Edge throw IndexSizeError
|
// Internet Explorer and Microsoft Edge throw IndexSizeError
|
||||||
// when you call context.drawImage with negative x or y
|
// when you call context.drawImage with negative x or y
|
||||||
// or width or height greater than the canvas width or height respectively
|
// or width or height greater than the canvas width or height respectively
|
||||||
if (bounds.x < 0) {
|
if (bounds.x < 0) {
|
||||||
bounds.width += bounds.x;
|
bounds.width += bounds.x;
|
||||||
@ -439,7 +443,7 @@ $.Drawer.prototype = {
|
|||||||
if (bounds.height > this.canvas.height) {
|
if (bounds.height > this.canvas.height) {
|
||||||
bounds.height = this.canvas.height;
|
bounds.height = this.canvas.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.context.drawImage(
|
this.context.drawImage(
|
||||||
this.sketchCanvas,
|
this.sketchCanvas,
|
||||||
bounds.x,
|
bounds.x,
|
||||||
|
Loading…
Reference in New Issue
Block a user