jellies-draw 0.2.2 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jellies-draw",
3
- "version": "0.2.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
- if (Properties.isUsingDrawingTool) {
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
  }
@@ -25,9 +25,9 @@ export default new Vue({
25
25
  50: 'XL'
26
26
  },
27
27
  strokeWidthOptions: {
28
- 3: 'H',
29
- 4: 'HB',
30
- 5: 'B',
28
+ 2: 'H',
29
+ 3: 'HB',
30
+ 4: 'B',
31
31
  6: '2B'
32
32
  }
33
33
  }
@@ -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,
@@ -55,6 +55,7 @@ export default {
55
55
  if (!this.temporalShape && newEllipse.radiusX() < 5 && newEllipse.radiusY() < 5) {
56
56
  newEllipse.radiusX(15)
57
57
  newEllipse.radiusY(15)
58
+ Histories.record()
58
59
  }
59
60
  }, 200)
60
61
  },
@@ -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,
@@ -53,6 +53,7 @@ export default {
53
53
  if (!this.temporalShape && newRectangle.width() < 5 && newRectangle.height() < 5) {
54
54
  newRectangle.width(30)
55
55
  newRectangle.height(30)
56
+ Histories.record()
56
57
  }
57
58
  }, 200)
58
59
  },
@@ -27,8 +27,13 @@ export default {
27
27
  return selectedNodes;
28
28
  },
29
29
  removeSelectedNodes() {
30
- this._nodes().forEach((node) => node.destroy());
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) {