konva 8.2.0 → 8.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/README.md CHANGED
@@ -130,7 +130,7 @@ npm install konva canvas
130
130
 
131
131
  ### CommonJS modules
132
132
 
133
- By default `Konva` is delivered as ES modules. If you need to use CommonJS modules you should use `cmj` bundled version:
133
+ By default `Konva` is delivered as ES modules. Some environments may automatically take CommonJS version of `Konva`. If it doesn't work for you, try to use `cmj` version explicitly:
134
134
 
135
135
  ```js
136
136
  const Konva = require('konva/cmj').default;
package/cmj/Util.js CHANGED
@@ -737,7 +737,7 @@ exports.Util = {
737
737
  },
738
738
  _getFirstPointerId(evt) {
739
739
  if (!evt.touches) {
740
- return 999;
740
+ return evt.pointerId || 999;
741
741
  }
742
742
  else {
743
743
  return evt.changedTouches[0].identifier;
@@ -11,6 +11,7 @@ export interface ArrowConfig extends LineConfig {
11
11
  }
12
12
  export declare class Arrow extends Line<ArrowConfig> {
13
13
  _sceneFunc(ctx: any): void;
14
+ __fillStroke(ctx: any): void;
14
15
  getSelfRect(): {
15
16
  x: number;
16
17
  y: number;
@@ -49,6 +49,7 @@ class Arrow extends Line_1.Line {
49
49
  ctx.lineTo(-length, -width / 2);
50
50
  ctx.closePath();
51
51
  ctx.restore();
52
+ this.__fillStroke(ctx);
52
53
  }
53
54
  if (this.pointerAtBeginning()) {
54
55
  ctx.save();
@@ -68,11 +69,10 @@ class Arrow extends Line_1.Line {
68
69
  ctx.lineTo(-length, -width / 2);
69
70
  ctx.closePath();
70
71
  ctx.restore();
72
+ this.__fillStroke(ctx);
71
73
  }
72
- const hasPointer = this.pointerAtEnding() || this.pointerAtBeginning();
73
- if (!hasPointer) {
74
- return;
75
- }
74
+ }
75
+ __fillStroke(ctx) {
76
76
  var isDashEnabled = this.dashEnabled();
77
77
  if (isDashEnabled) {
78
78
  this.attrs.dashEnabled = false;
@@ -44,6 +44,7 @@ export declare class Transformer extends Group {
44
44
  attachTo(node: any): this;
45
45
  setNode(node: any): this;
46
46
  getNode(): Node<import("../Node").NodeConfig>;
47
+ _getEventNamespace(): string;
47
48
  setNodes(nodes?: Array<Node>): this;
48
49
  _proxyDrag(node: Node): void;
49
50
  getNodes(): Node<import("../Node").NodeConfig>[];
@@ -42,9 +42,7 @@ var TRANSFORM_CHANGE_STR = [
42
42
  'offsetYChange',
43
43
  'transformsEnabledChange',
44
44
  'strokeWidthChange',
45
- ]
46
- .map((e) => e + `.${EVENTS_NAME}`)
47
- .join(' ');
45
+ ];
48
46
  var ANGLES = {
49
47
  'top-left': -45,
50
48
  'top-center': 0,
@@ -162,6 +160,9 @@ class Transformer extends Group_1.Group {
162
160
  getNode() {
163
161
  return this._nodes && this._nodes[0];
164
162
  }
163
+ _getEventNamespace() {
164
+ return EVENTS_NAME + this._id;
165
+ }
165
166
  setNodes(nodes = []) {
166
167
  if (this._nodes && this._nodes.length) {
167
168
  this.detach();
@@ -174,9 +175,6 @@ class Transformer extends Group_1.Group {
174
175
  this.rotation(0);
175
176
  }
176
177
  this._nodes.forEach((node) => {
177
- const additionalEvents = node._attrsAffectingSize
178
- .map((prop) => prop + 'Change.' + EVENTS_NAME)
179
- .join(' ');
180
178
  const onChange = () => {
181
179
  if (this.nodes().length === 1 && this.useSingleNodeRotation()) {
182
180
  this.rotation(this.nodes()[0].getAbsoluteRotation());
@@ -186,10 +184,12 @@ class Transformer extends Group_1.Group {
186
184
  this.update();
187
185
  }
188
186
  };
187
+ const additionalEvents = node._attrsAffectingSize
188
+ .map((prop) => prop + 'Change.' + this._getEventNamespace())
189
+ .join(' ');
189
190
  node.on(additionalEvents, onChange);
190
- node.on(TRANSFORM_CHANGE_STR, onChange);
191
- node.on(`absoluteTransformChange.${EVENTS_NAME}`, onChange);
192
- node.on(`xChange.${EVENTS_NAME} yChange.${EVENTS_NAME}`, onChange);
191
+ node.on(TRANSFORM_CHANGE_STR.map((e) => e + `.${this._getEventNamespace()}`).join(' '), onChange);
192
+ node.on(`absoluteTransformChange.${this._getEventNamespace()}`, onChange);
193
193
  this._proxyDrag(node);
194
194
  });
195
195
  this._resetTransformCache();
@@ -201,13 +201,13 @@ class Transformer extends Group_1.Group {
201
201
  }
202
202
  _proxyDrag(node) {
203
203
  let lastPos;
204
- node.on(`dragstart.${EVENTS_NAME}`, (e) => {
204
+ node.on(`dragstart.${this._getEventNamespace()}`, (e) => {
205
205
  lastPos = node.getAbsolutePosition();
206
206
  if (!this.isDragging() && node !== this.findOne('.back')) {
207
207
  this.startDrag(e, false);
208
208
  }
209
209
  });
210
- node.on(`dragmove.${EVENTS_NAME}`, (e) => {
210
+ node.on(`dragmove.${this._getEventNamespace()}`, (e) => {
211
211
  if (!lastPos) {
212
212
  return;
213
213
  }
@@ -240,7 +240,7 @@ class Transformer extends Group_1.Group {
240
240
  detach() {
241
241
  if (this._nodes) {
242
242
  this._nodes.forEach((node) => {
243
- node.off('.' + EVENTS_NAME);
243
+ node.off('.' + this._getEventNamespace());
244
244
  });
245
245
  }
246
246
  this._nodes = [];