jellies-draw 0.3.1 → 0.3.2

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.3.1",
3
+ "version": "0.3.2",
4
4
  "description": "A drawer for jellies",
5
5
  "private": false,
6
6
  "main": "./src/index.js",
@@ -110,7 +110,10 @@ export default {
110
110
  }
111
111
  },
112
112
  _handleKeydown(event) {
113
- if (!this.hasShortCuts || Properties.isCanvasPenetrable) {
113
+ if (!this.hasShortCuts) {
114
+ return
115
+ }
116
+ if (Properties.isCanvasPenetrable && !event.shiftKey) {
114
117
  return
115
118
  }
116
119
  if (event.key === 'Escape') {
@@ -1,7 +1,7 @@
1
1
  import Konva from 'konva';
2
+ import Properties from './properties';
2
3
 
3
4
  const FADE_DURATION = 700;
4
- const LASER_WIDTH = 4;
5
5
  const DRAG_THRESHOLD = 2;
6
6
  const GLOW_COLOR = '243, 59, 41';
7
7
  const CORE_COLOR = '255, 110, 90';
@@ -62,6 +62,8 @@ export default {
62
62
  window.addEventListener('pointermove', this._onMouseMove, true);
63
63
  window.addEventListener('pointerup', this._onMouseUp, true);
64
64
  window.addEventListener('pointercancel', this._onMouseUp, true);
65
+ this._previousUserSelect = document.body.style.userSelect;
66
+ document.body.style.userSelect = 'none';
65
67
  this.rafId = requestAnimationFrame(this._onTick);
66
68
  },
67
69
 
@@ -72,6 +74,8 @@ export default {
72
74
  window.removeEventListener('pointermove', this._onMouseMove, true);
73
75
  window.removeEventListener('pointerup', this._onMouseUp, true);
74
76
  window.removeEventListener('pointercancel', this._onMouseUp, true);
77
+ document.body.style.userSelect = this._previousUserSelect || '';
78
+ this._previousUserSelect = null;
75
79
  if (this.rafId !== null) {
76
80
  cancelAnimationFrame(this.rafId);
77
81
  this.rafId = null;
@@ -137,9 +141,15 @@ export default {
137
141
  }
138
142
  this.lastX = pt.x;
139
143
  this.lastY = pt.y;
144
+ e.stopPropagation();
145
+ e.preventDefault();
140
146
  },
141
147
 
142
- _handleMouseUp() {
148
+ _handleMouseUp(e) {
149
+ if (this.hasDragged) {
150
+ e.stopPropagation();
151
+ e.preventDefault();
152
+ }
143
153
  this.isPressed = false;
144
154
  this.hasDragged = false;
145
155
  },
@@ -175,12 +185,13 @@ export default {
175
185
  ctx.lineTo(segs[i].x2, segs[i].y2);
176
186
  }
177
187
 
188
+ const coreWidth = Properties.strokeWidth || 4;
178
189
  ctx.strokeStyle = `rgba(${GLOW_COLOR}, ${opacity * 0.3})`;
179
- ctx.lineWidth = LASER_WIDTH * 2.5;
190
+ ctx.lineWidth = coreWidth * 2.5;
180
191
  ctx.stroke();
181
192
 
182
193
  ctx.strokeStyle = `rgba(${CORE_COLOR}, ${opacity})`;
183
- ctx.lineWidth = LASER_WIDTH;
194
+ ctx.lineWidth = coreWidth;
184
195
  ctx.stroke();
185
196
 
186
197
  ctx.restore();