jellies-draw 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -2
- package/src/components/functions/canvas.js +1 -3
- package/src/components/functions/clipboard.js +3 -1
- package/src/components/functions/histories.js +2 -0
- package/src/components/functions/tools/arrow.js +3 -1
- package/src/components/functions/tools/ellipse.js +1 -0
- package/src/components/functions/tools/line.js +3 -1
- package/src/components/functions/tools/pen.js +5 -1
- package/src/components/functions/tools/rectangle.js +1 -0
- package/src/components/functions/transformer.js +8 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jellies-draw",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.4",
|
|
4
4
|
"description": "A drawer for jellies",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./src/index.js",
|
|
@@ -59,5 +59,8 @@
|
|
|
59
59
|
"> 1%",
|
|
60
60
|
"last 2 versions",
|
|
61
61
|
"not dead"
|
|
62
|
-
]
|
|
62
|
+
],
|
|
63
|
+
"resolutions": {
|
|
64
|
+
"vue-loader": "^15.11.1"
|
|
65
|
+
}
|
|
63
66
|
}
|
|
@@ -38,9 +38,7 @@ export default {
|
|
|
38
38
|
this.stage.on('pointerup', this.handleCanvasPointerUp);
|
|
39
39
|
this.stage.on('click tap', this.clickHandler);
|
|
40
40
|
this.stage.on('pointerdown', () => {
|
|
41
|
-
|
|
42
|
-
window.addEventListener('pointerup', this.handleGlobalPointerUp, { once: true });
|
|
43
|
-
}
|
|
41
|
+
window.addEventListener('pointerup', this.handleGlobalPointerUp, { once: true });
|
|
44
42
|
});
|
|
45
43
|
this.stage.on('mousemove', this._handleMouseMove.bind(this));
|
|
46
44
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import Canvas from './canvas';
|
|
2
2
|
import Transformer from './transformer';
|
|
3
3
|
import Tools from './tools';
|
|
4
|
+
import Histories from './histories';
|
|
4
5
|
export default {
|
|
5
6
|
copiedNodes: [],
|
|
6
7
|
copy() {
|
|
@@ -11,7 +12,7 @@ export default {
|
|
|
11
12
|
Transformer.removeSelectedNodes();
|
|
12
13
|
},
|
|
13
14
|
paste() {
|
|
14
|
-
if (this.copiedNodes) {
|
|
15
|
+
if (this.copiedNodes && this.copiedNodes.length > 0) {
|
|
15
16
|
this.copiedNodes.forEach((node) => {
|
|
16
17
|
node.x(node.x() + 10);
|
|
17
18
|
node.y(node.y() + 10);
|
|
@@ -20,6 +21,7 @@ export default {
|
|
|
20
21
|
});
|
|
21
22
|
Transformer.selectNodes(this.copiedNodes);
|
|
22
23
|
this.copiedNodes = Transformer.copySelectedNodes();
|
|
24
|
+
Histories.record();
|
|
23
25
|
}
|
|
24
26
|
},
|
|
25
27
|
_addEventsToCopiedNode(node) {
|
|
@@ -23,12 +23,14 @@ export default new Vue({
|
|
|
23
23
|
},
|
|
24
24
|
undo() {
|
|
25
25
|
if (this.historyIndex > 0) {
|
|
26
|
+
clearTimeout(this.recordTimer)
|
|
26
27
|
this.historyIndex--
|
|
27
28
|
this.refreshNodes()
|
|
28
29
|
}
|
|
29
30
|
},
|
|
30
31
|
redo() {
|
|
31
32
|
if (this.historyIndex < this.histories.length - 1) {
|
|
33
|
+
clearTimeout(this.recordTimer)
|
|
32
34
|
this.historyIndex++
|
|
33
35
|
this.refreshNodes()
|
|
34
36
|
}
|
|
@@ -59,12 +59,14 @@ export default {
|
|
|
59
59
|
newArrow.on('transformend', Histories.record)
|
|
60
60
|
newArrow.on('dragend', Histories.record)
|
|
61
61
|
},
|
|
62
|
-
generate({ x, y, scaleX, scaleY, points, stroke, strokeWidth, pointerWidth, pointerLength }) {
|
|
62
|
+
generate({ x, y, scaleX, scaleY, skewX, rotation, points, stroke, strokeWidth, pointerWidth, pointerLength }) {
|
|
63
63
|
const newArrow = new Konva.Arrow({
|
|
64
64
|
x,
|
|
65
65
|
y,
|
|
66
66
|
scaleX,
|
|
67
67
|
scaleY,
|
|
68
|
+
skewX,
|
|
69
|
+
rotation,
|
|
68
70
|
points,
|
|
69
71
|
stroke,
|
|
70
72
|
strokeWidth,
|
|
@@ -41,12 +41,14 @@ export default {
|
|
|
41
41
|
}
|
|
42
42
|
this.temporalShape = null
|
|
43
43
|
},
|
|
44
|
-
generate({ x, y, scaleX, scaleY, points, stroke, strokeWidth }) {
|
|
44
|
+
generate({ x, y, scaleX, scaleY, skewX, rotation, points, stroke, strokeWidth }) {
|
|
45
45
|
const newLine = new Konva.Line({
|
|
46
46
|
x,
|
|
47
47
|
y,
|
|
48
48
|
scaleX,
|
|
49
49
|
scaleY,
|
|
50
|
+
skewX,
|
|
51
|
+
rotation,
|
|
50
52
|
points,
|
|
51
53
|
stroke,
|
|
52
54
|
strokeWidth,
|
|
@@ -77,7 +77,7 @@ export default {
|
|
|
77
77
|
this.temporalShape = null
|
|
78
78
|
},
|
|
79
79
|
|
|
80
|
-
generate({ points, widths, stroke, x, y, width, height }) {
|
|
80
|
+
generate({ points, widths, stroke, x, y, width, height, scaleX, scaleY, skewX, rotation }) {
|
|
81
81
|
const tool = this
|
|
82
82
|
|
|
83
83
|
const shape = new Konva.Shape({
|
|
@@ -85,6 +85,10 @@ export default {
|
|
|
85
85
|
y: y || 0,
|
|
86
86
|
width: width || 0,
|
|
87
87
|
height: height || 0,
|
|
88
|
+
scaleX,
|
|
89
|
+
scaleY,
|
|
90
|
+
skewX,
|
|
91
|
+
rotation,
|
|
88
92
|
stroke,
|
|
89
93
|
points,
|
|
90
94
|
widths,
|
|
@@ -27,8 +27,13 @@ export default {
|
|
|
27
27
|
return selectedNodes;
|
|
28
28
|
},
|
|
29
29
|
removeSelectedNodes() {
|
|
30
|
-
this._nodes()
|
|
30
|
+
const nodes = this._nodes();
|
|
31
|
+
if (nodes.length === 0) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
nodes.forEach((node) => node.destroy());
|
|
31
35
|
this.deselectAllNodes();
|
|
36
|
+
Histories.record();
|
|
32
37
|
},
|
|
33
38
|
setPropertiesOfSelectedNodes(properties) {
|
|
34
39
|
const selectedNodes = this._nodes().slice();
|
|
@@ -279,6 +284,7 @@ export default {
|
|
|
279
284
|
});
|
|
280
285
|
|
|
281
286
|
this.dragArea.off('dragmove');
|
|
287
|
+
this.dragArea.off('dragend');
|
|
282
288
|
this.dragArea.on('dragmove', () => {
|
|
283
289
|
const dx = this.dragArea.x() - box.x;
|
|
284
290
|
const dy = this.dragArea.y() - box.y;
|
|
@@ -289,6 +295,7 @@ export default {
|
|
|
289
295
|
box.x = this.dragArea.x();
|
|
290
296
|
box.y = this.dragArea.y();
|
|
291
297
|
});
|
|
298
|
+
this.dragArea.on('dragend', () => Histories.record());
|
|
292
299
|
},
|
|
293
300
|
_updateTransformerAnchors(targetNodes) {
|
|
294
301
|
if (targetNodes.length === 1) {
|