konva 10.1.0 → 10.2.0

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/konva.js CHANGED
@@ -5,10 +5,10 @@
5
5
  })(this, (function () { 'use strict';
6
6
 
7
7
  /*
8
- * Konva JavaScript Framework v10.1.0
8
+ * Konva JavaScript Framework v10.2.0
9
9
  * http://konvajs.org/
10
10
  * Licensed under the MIT
11
- * Date: Wed Jan 14 2026
11
+ * Date: Thu Jan 15 2026
12
12
  *
13
13
  * Original work Copyright (C) 2011 - 2013 by Eric Rowell (KineticJS)
14
14
  * Modified work Copyright (C) 2014 - present by Anton Lavrenov (Konva)
@@ -35,7 +35,7 @@
35
35
  : {};
36
36
  const Konva$2 = {
37
37
  _global: glob,
38
- version: '10.1.0',
38
+ version: '10.2.0',
39
39
  isBrowser: detectBrowser(),
40
40
  isUnminified: /param/.test(function (param) { }.toString()),
41
41
  dblClickWindow: 400,
@@ -16167,6 +16167,7 @@ js: import "konva/skia-backend";
16167
16167
  const ATTR_CHANGE_LIST = [
16168
16168
  'resizeEnabledChange',
16169
16169
  'rotateAnchorOffsetChange',
16170
+ 'rotateAnchorAngleChange',
16170
16171
  'rotateEnabledChange',
16171
16172
  'enabledAnchorsChange',
16172
16173
  'anchorSizeChange',
@@ -16673,11 +16674,44 @@ js: import "konva/skia-backend";
16673
16674
  sceneFunc(ctx, shape) {
16674
16675
  const tr = shape.getParent();
16675
16676
  const padding = tr.padding();
16677
+ const width = shape.width();
16678
+ const height = shape.height();
16676
16679
  ctx.beginPath();
16677
- ctx.rect(-padding, -padding, shape.width() + padding * 2, shape.height() + padding * 2);
16678
- ctx.moveTo(shape.width() / 2, -padding);
16680
+ ctx.rect(-padding, -padding, width + padding * 2, height + padding * 2);
16679
16681
  if (tr.rotateEnabled() && tr.rotateLineVisible()) {
16680
- ctx.lineTo(shape.width() / 2, -tr.rotateAnchorOffset() * Util._sign(shape.height()) - padding);
16682
+ // Calculate rotation line position based on rotateAnchorAngle
16683
+ const rotateAnchorAngle = tr.rotateAnchorAngle();
16684
+ const rotateAnchorOffset = tr.rotateAnchorOffset();
16685
+ const rad = Util.degToRad(rotateAnchorAngle);
16686
+ // Direction vector (0 degrees = up/top)
16687
+ const dirX = Math.sin(rad);
16688
+ const dirY = -Math.cos(rad);
16689
+ // Center of the box
16690
+ const cx = width / 2;
16691
+ const cy = height / 2;
16692
+ // Find intersection with box edge
16693
+ let t = Infinity;
16694
+ if (dirY < 0) {
16695
+ t = Math.min(t, -cy / dirY);
16696
+ }
16697
+ else if (dirY > 0) {
16698
+ t = Math.min(t, (height - cy) / dirY);
16699
+ }
16700
+ if (dirX < 0) {
16701
+ t = Math.min(t, -cx / dirX);
16702
+ }
16703
+ else if (dirX > 0) {
16704
+ t = Math.min(t, (width - cx) / dirX);
16705
+ }
16706
+ // Edge point (start of line)
16707
+ const edgeX = cx + dirX * t;
16708
+ const edgeY = cy + dirY * t;
16709
+ // End point with offset
16710
+ const sign = Util._sign(height);
16711
+ const endX = edgeX + dirX * rotateAnchorOffset * sign;
16712
+ const endY = edgeY + dirY * rotateAnchorOffset * sign;
16713
+ ctx.moveTo(edgeX, edgeY);
16714
+ ctx.lineTo(endX, endY);
16681
16715
  }
16682
16716
  ctx.fillStrokeShape(shape);
16683
16717
  },
@@ -16767,8 +16801,10 @@ js: import "konva/skia-backend";
16767
16801
  const attrs = this._getNodeRect();
16768
16802
  x = anchorNode.x() - attrs.width / 2;
16769
16803
  y = -anchorNode.y() + attrs.height / 2;
16770
- // hor angle is changed?
16771
- let delta = Math.atan2(-y, x) + Math.PI / 2;
16804
+ // Calculate angle from center to current anchor position
16805
+ // Offset by rotateAnchorAngle so we measure rotation from the anchor's starting position
16806
+ const rotateAnchorAngleRad = Konva$2.getAngle(this.rotateAnchorAngle());
16807
+ let delta = Math.atan2(-y, x) + Math.PI / 2 - rotateAnchorAngleRad;
16772
16808
  if (attrs.height < 0) {
16773
16809
  delta -= Math.PI;
16774
16810
  }
@@ -17195,9 +17231,44 @@ js: import "konva/skia-backend";
17195
17231
  offsetY: anchorSize / 2 - padding,
17196
17232
  visible: resizeEnabled && enabledAnchors.indexOf('bottom-right') >= 0,
17197
17233
  });
17234
+ // Calculate rotation anchor position based on rotateAnchorAngle
17235
+ const rotateAnchorAngle = this.rotateAnchorAngle();
17236
+ const rotateAnchorOffset = this.rotateAnchorOffset();
17237
+ const rad = Util.degToRad(rotateAnchorAngle);
17238
+ // Direction vector (0 degrees = up/top)
17239
+ const dirX = Math.sin(rad);
17240
+ const dirY = -Math.cos(rad);
17241
+ // Center of the box
17242
+ const cx = width / 2;
17243
+ const cy = height / 2;
17244
+ // Find intersection with box edge
17245
+ // Calculate time to hit each edge from center
17246
+ let t = Infinity;
17247
+ // Handle each direction
17248
+ if (dirY < 0) {
17249
+ // Moving up, check top edge (y = 0)
17250
+ t = Math.min(t, -cy / dirY);
17251
+ }
17252
+ else if (dirY > 0) {
17253
+ // Moving down, check bottom edge (y = height)
17254
+ t = Math.min(t, (height - cy) / dirY);
17255
+ }
17256
+ if (dirX < 0) {
17257
+ // Moving left, check left edge (x = 0)
17258
+ t = Math.min(t, -cx / dirX);
17259
+ }
17260
+ else if (dirX > 0) {
17261
+ // Moving right, check right edge (x = width)
17262
+ t = Math.min(t, (width - cx) / dirX);
17263
+ }
17264
+ // Edge point
17265
+ const edgeX = cx + dirX * t;
17266
+ const edgeY = cy + dirY * t;
17267
+ // Final position with offset (accounting for height sign and padding)
17268
+ const sign = Util._sign(height);
17198
17269
  this._batchChangeChild('.rotater', {
17199
- x: width / 2,
17200
- y: -this.rotateAnchorOffset() * Util._sign(height) - padding,
17270
+ x: edgeX + dirX * rotateAnchorOffset * sign,
17271
+ y: edgeY + dirY * rotateAnchorOffset * sign - padding * dirY,
17201
17272
  visible: this.rotateEnabled(),
17202
17273
  });
17203
17274
  this._batchChangeChild('.back', {
@@ -17406,6 +17477,24 @@ js: import "konva/skia-backend";
17406
17477
  * transformer.rotateAnchorOffset(100);
17407
17478
  */
17408
17479
  Factory.addGetterSetter(Transformer, 'rotateAnchorOffset', 50, getNumberValidator());
17480
+ /**
17481
+ * get/set the angle (in degrees) of the rotation anchor position around the bounding box.
17482
+ * 0 = top-center (default), 90 = middle-right, 180 = bottom-center, -90 = middle-left
17483
+ * @name Konva.Transformer#rotateAnchorAngle
17484
+ * @method
17485
+ * @param {Number} angle
17486
+ * @returns {Number}
17487
+ * @example
17488
+ * // get
17489
+ * var rotateAnchorAngle = transformer.rotateAnchorAngle();
17490
+ *
17491
+ * // set rotation anchor to the right side
17492
+ * transformer.rotateAnchorAngle(90);
17493
+ *
17494
+ * // set rotation anchor to the bottom
17495
+ * transformer.rotateAnchorAngle(180);
17496
+ */
17497
+ Factory.addGetterSetter(Transformer, 'rotateAnchorAngle', 0, getNumberValidator());
17409
17498
  /**
17410
17499
  * get/set rotation anchor cursor
17411
17500
  * @name Konva.Transformer#rotateAnchorCursor