Fixes for 3D image
* URL needs to be URI encoded, else Firefox won't cope * Hide / Show 3D overlay instead of removing / re-adding
This commit is contained in:
@@ -6,7 +6,11 @@ function ThreeDHandler(canvas) {
|
|||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
_overlay.addWithUpdate(new fabric.Rect({
|
_overlay
|
||||||
|
.set({
|
||||||
|
visible: false
|
||||||
|
})
|
||||||
|
.addWithUpdate(new fabric.Rect({
|
||||||
width: canvas.width,
|
width: canvas.width,
|
||||||
height: canvas.height - 60,
|
height: canvas.height - 60,
|
||||||
top: 60,
|
top: 60,
|
||||||
@@ -19,21 +23,16 @@ function ThreeDHandler(canvas) {
|
|||||||
init();
|
init();
|
||||||
|
|
||||||
this.disable = function () {
|
this.disable = function () {
|
||||||
canvas.remove(_overlay);
|
_overlay.setVisible(false).canvas.renderAll();
|
||||||
canvas.renderAll();
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.enable = function () {
|
this.enable = function () {
|
||||||
if (!_overlay.canvas) {
|
_overlay.setVisible(true).canvas.renderAll();
|
||||||
canvas.add(_overlay);
|
|
||||||
}
|
|
||||||
canvas.renderAll();
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.setImage = function (img) {
|
this.setImage = function (img) {
|
||||||
this.enable();
|
|
||||||
img.set({
|
img.set({
|
||||||
originX: 'center',
|
originX: 'center',
|
||||||
originY: 'center',
|
originY: 'center',
|
||||||
@@ -43,7 +42,7 @@ function ThreeDHandler(canvas) {
|
|||||||
.remove(_image)
|
.remove(_image)
|
||||||
.add(_image = img);
|
.add(_image = img);
|
||||||
|
|
||||||
return this;
|
return this.enable();
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
|
|
||||||
var Canvas = require('./Canvas');
|
var Canvas = require('./Canvas');
|
||||||
var util = require('../util');
|
var util = require('../util');
|
||||||
var config = require('../config');
|
|
||||||
|
|
||||||
function ImageEditor(canvasId, args) {
|
function ImageEditor(canvasId, args) {
|
||||||
var _canvas;
|
var _canvas;
|
||||||
@@ -111,10 +110,10 @@ function ImageEditor(canvasId, args) {
|
|||||||
|
|
||||||
this.toggle3D = function (showAs3d) {
|
this.toggle3D = function (showAs3d) {
|
||||||
if (!showAs3d) {
|
if (!showAs3d) {
|
||||||
return this.loadImage(this._url);
|
return _canvas.get3dHandler().disable();
|
||||||
}
|
}
|
||||||
|
|
||||||
fabric.Image.fromURL(this.get3dUrl(), function (img) {
|
fabric.Image.fromURL(encodeURI(this.get3dUrl()), function (img) {
|
||||||
_canvas.get3dHandler().setImage(img);
|
_canvas.get3dHandler().setImage(img);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user