Skip to content

Commit 9517c91

Browse files
committed
fix minor bugs
1 parent 5948f72 commit 9517c91

File tree

3 files changed

+38
-3
lines changed

3 files changed

+38
-3
lines changed

lib/canvasSettings.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@
9292
let target = $(this).data('value');
9393
$(this).closest('.tab-container').find('.tab-content').hide();
9494
$(this).closest('.tab-container').find(`.tab-content[data-value=${target}]`).show();
95+
96+
if (target === 'color-fill') {
97+
let color = $(`${_self.containerSelector} .toolpanel#background-panel .content #color-picker`).val();
98+
try {
99+
_self.canvas.backgroundColor = color;
100+
_self.canvas.renderAll();
101+
} catch (_) {
102+
console.log("can't update background color")
103+
}
104+
} else {
105+
updateGradientFill();
106+
}
95107
})
96108

97109
$(`${this.containerSelector} .toolpanel#background-panel .content .tab-label[data-value=color-fill]`).click();
@@ -104,7 +116,8 @@
104116
showInput: "true",
105117
allowEmpty: "false",
106118
move: function (color) {
107-
let hex = color.toRgbString(); // #ff0000
119+
let hex = 'transparent';
120+
color && (hex = color.toRgbString()); // #ff0000
108121
_self.canvas.backgroundColor = hex;
109122
_self.canvas.renderAll();
110123
}

lib/core.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,12 @@
2828
}
2929
}
3030

31+
if (id !== 'select') {
32+
this.canvas.discardActiveObject();
33+
this.canvas.renderAll();
34+
this.activeSelection = null;
35+
}
36+
3137
this.canvas.isDrawingLineMode = false;
3238
this.canvas.isDrawingPathMode = false;
3339
this.canvas.isDrawingMode = false;

lib/selectionSettings.js

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
/**
2+
* initialize selection setting panel
3+
*/
14
(function () {
25
'use strict';
36
const BorderStyleList = [{
@@ -251,7 +254,8 @@
251254
showInput: "true",
252255
allowEmpty: "false",
253256
move: function (color) {
254-
let hex = color.toRgbString(); // #ff0000let color = $(this).val();
257+
let hex = 'transparent';
258+
color && (hex = color.toRgbString()); // #ff0000
255259
_self.canvas.getActiveObjects().forEach(obj => obj.set('stroke', hex))
256260
_self.canvas.renderAll(), _self.canvas.trigger('object:modified')
257261
}
@@ -328,6 +332,17 @@
328332
let target = $(this).data('value');
329333
$(this).closest('.tab-container').find('.tab-content').hide();
330334
$(this).closest('.tab-container').find(`.tab-content[data-value=${target}]`).show();
335+
if (target === 'color-fill') {
336+
let color = $(`${_self.containerSelector} .toolpanel#select-panel .fill-section #color-picker`).val();
337+
try {
338+
_self.canvas.getActiveObjects().forEach(obj => obj.set('fill', color))
339+
_self.canvas.renderAll(), _self.canvas.trigger('object:modified')
340+
} catch (_) {
341+
console.log("can't update background color")
342+
}
343+
} else {
344+
updateGradientFill();
345+
}
331346
})
332347

333348
$(`${_self.containerSelector} .toolpanel#select-panel .content .tab-label[data-value=color-fill]`).click();
@@ -340,7 +355,8 @@
340355
showInput: "true",
341356
allowEmpty: "false",
342357
move: function (color) {
343-
let hex = color.toRgbString(); // #ff0000
358+
let hex = 'transparent';
359+
color && (hex = color.toRgbString()); // #ff0000
344360
_self.canvas.getActiveObjects().forEach(obj => obj.set('fill', hex))
345361
_self.canvas.renderAll(), _self.canvas.trigger('object:modified')
346362
}

0 commit comments

Comments
 (0)