jellies-draw 0.1.2 → 0.1.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.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "A drawer for jellies",
5
5
  "private": false,
6
6
  "main": "./src/index.js",
@@ -11,6 +11,9 @@
11
11
  'cursor-crosshair': isCrosshairCursorActive
12
12
  }
13
13
  ]"
14
+ :style="{
15
+ backgroundColor: backgroundColor
16
+ }"
14
17
  />
15
18
  </div>
16
19
  </template>
@@ -20,6 +23,12 @@ import Canvas from './functions/canvas';
20
23
  import Properties from './functions/properties';
21
24
  export default {
22
25
  name: 'DrawingCanvas',
26
+ props: {
27
+ backgroundColor: {
28
+ type: String,
29
+ default: 'transparent'
30
+ }
31
+ },
23
32
  computed: {
24
33
  canvas() {
25
34
  return this.$refs.whiteboard
@@ -57,9 +66,6 @@ export default {
57
66
  width: 100%;
58
67
  height: 100%;
59
68
  }
60
- .whiteboard {
61
- background-color: yellow;
62
- }
63
69
  .cursor-crosshair {
64
70
  cursor: crosshair;
65
71
  }
@@ -20,6 +20,7 @@
20
20
  import ToolButton from './ToolButton.vue'
21
21
  import Properties from './functions/properties'
22
22
  import Tools from './functions/tools'
23
+ import Canvas from './functions/canvas'
23
24
  export default {
24
25
  name: 'ToolButtons',
25
26
  components: {
@@ -66,6 +67,9 @@ export default {
66
67
  watch: {
67
68
  currentTool(newTool) {
68
69
  this.currentTool = newTool;
70
+ },
71
+ hasShortCuts(hasShortCuts) {
72
+ Canvas.hasShortCuts = hasShortCuts
69
73
  }
70
74
  },
71
75
  methods: {
@@ -16,7 +16,7 @@ export default {
16
16
  clickHandler: null,
17
17
  isEditingText: false,
18
18
  isDrawing: false,
19
- isRecording: false,
19
+ hasShortCuts: false,
20
20
  initialize(canvas, container) {
21
21
  this.container = container
22
22
  this.generateEventHandlers()
@@ -66,6 +66,9 @@ export default {
66
66
  }
67
67
  },
68
68
  _handleKeydown(event) {
69
+ if (!this.hasShortCuts) {
70
+ return
71
+ }
69
72
  if (event.key === 'Escape') {
70
73
  Transformer.deselectAllNodes();
71
74
  } else if (event.key === 'Backspace') {
@@ -7,22 +7,19 @@ import Properties from './properties'
7
7
  export default new Vue({
8
8
  data() {
9
9
  return {
10
+ recordTimer: null,
10
11
  histories: [],
11
12
  historyIndex: -1
12
13
  }
13
14
  },
14
15
  methods: {
15
16
  record() {
16
- if (Canvas.isRecording) {
17
- return
18
- }
19
- Canvas.isRecording = true
20
- this.histories.splice(this.historyIndex + 1)
21
- this.histories.push(Canvas.layer.toJSON())
22
- this.historyIndex++
23
- this.$nextTick(() => {
24
- Canvas.isRecording = false
25
- })
17
+ clearTimeout(this.recordTimer)
18
+ this.recordTimer = setTimeout(() => {
19
+ this.histories.splice(this.historyIndex + 1)
20
+ this.histories.push(Canvas.layer.toJSON())
21
+ this.historyIndex++
22
+ }, 50)
26
23
  },
27
24
  undo() {
28
25
  if (this.historyIndex > 0) {
@@ -35,6 +35,7 @@ export default {
35
35
  node.setAttr(key, properties[key]);
36
36
  }
37
37
  });
38
+ Histories.record()
38
39
  });
39
40
  },
40
41
  selectNode(targetNode, isAppending = false) {