Skip to content

Commit

Permalink
Fix image picking issue with GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
deltakosh committed Oct 17, 2019
1 parent 9479ecf commit f29758a
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions gui/src/2D/controls/image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { _TypeStore } from 'babylonjs/Misc/typeStore';
* Class used to create 2D images
*/
export class Image extends Control {
private static _WorkingCanvas: Nullable<HTMLCanvasElement> = null;
private _workingCanvas: Nullable<HTMLCanvasElement> = null;

private _domImage: HTMLImageElement;
private _imageWidth: number;
Expand Down Expand Up @@ -299,10 +299,10 @@ export class Image extends Control {
}

private _extractNinePatchSliceDataFromImage() {
if (!Image._WorkingCanvas) {
Image._WorkingCanvas = document.createElement('canvas');
if (!this._workingCanvas) {
this._workingCanvas = document.createElement('canvas');
}
const canvas = Image._WorkingCanvas;
const canvas = this._workingCanvas;
const context = canvas.getContext('2d')!;
const width = this._domImage.width;
const height = this._domImage.height;
Expand Down Expand Up @@ -518,11 +518,11 @@ export class Image extends Control {
return false;
}

if (!this._detectPointerOnOpaqueOnly || !Image._WorkingCanvas) {
if (!this._detectPointerOnOpaqueOnly || !this._workingCanvas) {
return true;
}

const canvas = Image._WorkingCanvas;
const canvas = this._workingCanvas;
const context = canvas.getContext("2d")!;
const width = this._currentMeasure.width | 0;
const height = this._currentMeasure.height | 0;
Expand Down Expand Up @@ -581,10 +581,10 @@ export class Image extends Control {
return;
}

if (!Image._WorkingCanvas) {
Image._WorkingCanvas = document.createElement('canvas');
if (!this._workingCanvas) {
this._workingCanvas = document.createElement('canvas');
}
const canvas = Image._WorkingCanvas;
const canvas = this._workingCanvas;
const width = this._currentMeasure.width;
const height = this._currentMeasure.height;
const context = canvas.getContext("2d")!;
Expand All @@ -604,7 +604,7 @@ export class Image extends Control {
return;
}

const canvas = Image._WorkingCanvas!;
const canvas = this._workingCanvas!;
context = canvas.getContext("2d")!;

context.drawImage(this._domImage,
Expand Down

0 comments on commit f29758a

Please sign in to comment.