konva 10.7.0 → 10.8.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.7.0
8
+ * Konva JavaScript Framework v10.8.0
9
9
  * http://konvajs.org/
10
10
  * Licensed under the MIT
11
- * Date: Wed Sep 23 2026
11
+ * Date: Mon Oct 12 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.7.0',
38
+ version: '10.8.0',
39
39
  isBrowser: detectBrowser(),
40
40
  isUnminified: /param/.test(function (param) { }.toString()),
41
41
  dblClickWindow: 400,
@@ -4352,6 +4352,10 @@ js: import "konva/skia-backend";
4352
4352
  };
4353
4353
  for (key in attrs) {
4354
4354
  val = attrs[key];
4355
+ // JSON has no typed arrays, so typed line points are written as an array
4356
+ if (val instanceof TypedArray) {
4357
+ val = Array.from(val);
4358
+ }
4355
4359
  // if value is object and object is not plain
4356
4360
  // like class instance, we should skip it and to not include
4357
4361
  nonPlainObject =
@@ -5060,7 +5064,34 @@ js: import "konva/skia-backend";
5060
5064
  }
5061
5065
  return this;
5062
5066
  }
5067
+ _addSubtreeObserver(observer) {
5068
+ var _a;
5069
+ ((_a = this._subtreeObservers) !== null && _a !== void 0 ? _a : (this._subtreeObservers = new Set())).add(observer);
5070
+ Node._subtreeObserverCount++;
5071
+ }
5072
+ _removeSubtreeObserver(observer) {
5073
+ var _a;
5074
+ if ((_a = this._subtreeObservers) === null || _a === void 0 ? void 0 : _a.delete(observer)) {
5075
+ Node._subtreeObserverCount--;
5076
+ }
5077
+ }
5078
+ // Tells the observers of this node and of its ancestors that something below
5079
+ // them changed. A node's own changes reach its observers through its change
5080
+ // events, so a draw request starts at the parent. A container calls this
5081
+ // itself when its child list changes.
5082
+ _notifySubtreeChange() {
5083
+ if (!Node._subtreeObserverCount)
5084
+ return;
5085
+ for (let node = this; node; node = node.parent) {
5086
+ const observers = node._subtreeObservers;
5087
+ if (observers)
5088
+ for (const o of observers)
5089
+ o._onSubtreeChange(node);
5090
+ }
5091
+ }
5063
5092
  _requestDraw() {
5093
+ var _a;
5094
+ (_a = this.parent) === null || _a === void 0 ? void 0 : _a._notifySubtreeChange();
5064
5095
  if (Konva$2.autoDrawEnabled) {
5065
5096
  const drawNode = this.getLayer() || this.getStage();
5066
5097
  drawNode === null || drawNode === void 0 ? void 0 : drawNode.batchDraw();
@@ -5432,6 +5463,8 @@ js: import "konva/skia-backend";
5432
5463
  return no;
5433
5464
  }
5434
5465
  }
5466
+ // Number of registered observers. The ancestor walk is skipped while it is 0.
5467
+ Node._subtreeObserverCount = 0;
5435
5468
  // Perf: lets a listener inside an absoluteTransform cascade (e.g. Konva
5436
5469
  // .Transformer reacting to a stage drag fan-out across N attached nodes)
5437
5470
  // defer work until the cascade ends — collapses O(N) listener-driven calls
@@ -6074,6 +6107,7 @@ js: import "konva/skia-backend";
6074
6107
  });
6075
6108
  this.children = [];
6076
6109
  // because all children were detached from parent, request draw via container
6110
+ this._notifySubtreeChange();
6077
6111
  this._requestDraw();
6078
6112
  return this;
6079
6113
  }
@@ -6091,6 +6125,7 @@ js: import "konva/skia-backend";
6091
6125
  });
6092
6126
  this.children = [];
6093
6127
  // because all children were detached from parent, request draw via container
6128
+ this._notifySubtreeChange();
6094
6129
  this._requestDraw();
6095
6130
  return this;
6096
6131
  }
@@ -6129,6 +6164,7 @@ js: import "konva/skia-backend";
6129
6164
  this._fire('add', {
6130
6165
  child: child,
6131
6166
  });
6167
+ this._notifySubtreeChange();
6132
6168
  this._requestDraw();
6133
6169
  // chainable
6134
6170
  return this;
@@ -6329,6 +6365,7 @@ js: import "konva/skia-backend";
6329
6365
  (_a = this.children) === null || _a === void 0 ? void 0 : _a.forEach(function (child, n) {
6330
6366
  child.index = n;
6331
6367
  });
6368
+ this._notifySubtreeChange();
6332
6369
  this._requestDraw();
6333
6370
  }
6334
6371
  drawScene(can, top) {
@@ -8049,12 +8086,16 @@ js: import "konva/skia-backend";
8049
8086
  const forDrawing = config._forDrawing;
8050
8087
  // Painted bounds are measured in the canvas that draws the shape
8051
8088
  // (relativeTo): non-scaling strokes and shadows use that canvas's axes.
8052
- // The identity transform normalizes negative sizes.
8053
- const fillRect = !forDrawing
8054
- ? this.getSelfRect()
8055
- : this.strokeScaleEnabled()
8056
- ? new Transform()._getTransformedRect(this._getSelfRectForDrawing())
8057
- : this._transformedRect(this._getSelfRectForDrawing(), relativeTo);
8089
+ let fillRect = forDrawing
8090
+ ? this._getSelfRectForDrawing()
8091
+ : this.getSelfRect();
8092
+ if (forDrawing && !this.strokeScaleEnabled()) {
8093
+ fillRect = this._transformedRect(fillRect, relativeTo);
8094
+ }
8095
+ else if (fillRect.width < 0 || fillRect.height < 0) {
8096
+ // The identity transform normalizes negative sizes.
8097
+ fillRect = new Transform()._getTransformedRect(fillRect);
8098
+ }
8058
8099
  const applyStroke = !config.skipStroke && this.hasStroke();
8059
8100
  const strokeWidth = applyStroke
8060
8101
  ? forDrawing
@@ -16422,6 +16463,7 @@ js: import "konva/skia-backend";
16422
16463
  'rotateAnchorOffsetChange',
16423
16464
  'rotateAnchorAngleChange',
16424
16465
  'rotateEnabledChange',
16466
+ 'rotateModeChange',
16425
16467
  'enabledAnchorsChange',
16426
16468
  'anchorSizeChange',
16427
16469
  'borderEnabledChange',
@@ -16470,10 +16512,37 @@ js: import "konva/skia-backend";
16470
16512
  'bottom-right': 135,
16471
16513
  };
16472
16514
  const TOUCH_DEVICE = 'ontouchstart' in Konva$2._global;
16515
+ // invisible zones just outside the corners, the rotate area of rotateMode 'corners'
16516
+ const ROTATE_ZONE_NAMES = [
16517
+ 'rotater-top-left',
16518
+ 'rotater-top-right',
16519
+ 'rotater-bottom-left',
16520
+ 'rotater-bottom-right',
16521
+ ];
16522
+ function isRotateAnchor(anchorName) {
16523
+ return anchorName.startsWith('rotater');
16524
+ }
16525
+ // with Shift pressed the rotation snaps to this step
16526
+ const SHIFT_ROTATION_STEP = Math.PI / 12;
16527
+ // curved double arrow drawn for the top-right corner, rotated for others
16528
+ function getRotateZoneCursor(deg, fallback) {
16529
+ const svg = '<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24">' +
16530
+ `<g transform="rotate(${deg} 12 12)" stroke-linejoin="round">` +
16531
+ '<path d="M5 8 A11 11 0 0 1 16 19" fill="none" stroke="white" stroke-width="4"/>' +
16532
+ '<path d="M2 8 L6 4.5 L6 11.5 Z M16 22 L12.5 18 L19.5 18 Z" fill="black" stroke="white"/>' +
16533
+ '<path d="M5 8 A11 11 0 0 1 16 19" fill="none" stroke="black" stroke-width="1.5"/>' +
16534
+ '</g></svg>';
16535
+ return `url("data:image/svg+xml,${encodeURIComponent(svg)}") 12 12, ${fallback}`;
16536
+ }
16473
16537
  function getCursor(anchorName, rad, rotateCursor) {
16474
16538
  if (anchorName === 'rotater') {
16475
16539
  return rotateCursor;
16476
16540
  }
16541
+ if (isRotateAnchor(anchorName)) {
16542
+ const corner = anchorName.slice('rotater-'.length);
16543
+ const deg = Math.round(Util.radToDeg(rad) + ANGLES[corner] - 45);
16544
+ return getRotateZoneCursor(deg, rotateCursor);
16545
+ }
16477
16546
  rad += Util.degToRad(ANGLES[anchorName] || 0);
16478
16547
  const angle = ((Util.radToDeg(rad) % 360) + 360) % 360;
16479
16548
  if (Util._inRange(angle, 315 + 22.5, 360) || Util._inRange(angle, 0, 22.5)) {
@@ -16614,6 +16683,7 @@ js: import "konva/skia-backend";
16614
16683
  * @param {Number} [config.rotateAnchorOffset] Default is 50
16615
16684
  * @param {Number} [config.rotateAnchorAngle] Angle of the rotate anchor around the box, in degrees. Default is 0 (top)
16616
16685
  * @param {String} [config.rotateAnchorCursor] Default is crosshair
16686
+ * @param {String} [config.rotateMode] How the user rotates: 'handle' (the rotate anchor), 'corners' (invisible zones just outside the corners) or 'both'. Default is 'handle'
16617
16687
  * @param {Number} [config.padding] Default is 0
16618
16688
  * @param {Boolean} [config.borderEnabled] Should we draw border? Default is true
16619
16689
  * @param {String} [config.borderStroke] Border stroke color
@@ -16625,7 +16695,7 @@ js: import "konva/skia-backend";
16625
16695
  * @param {Number} [config.anchorStrokeWidth] Anchor stroke size
16626
16696
  * @param {Number} [config.anchorSize] Default is 10
16627
16697
  * @param {Boolean} [config.keepRatio] Should we keep ratio when we are moving edges? Default is true
16628
- * @param {String} [config.shiftBehavior] How does transformer react on shift key press when we are moving edges? Default is 'default'
16698
+ * @param {String} [config.shiftBehavior] How does transformer react on shift key press when we are moving edges? 'none' also turns off the Shift rotation snap. Default is 'default'
16629
16699
  * @param {Boolean} [config.centeredScaling] Should we resize relative to node's center? Default is false
16630
16700
  * @param {Array} [config.enabledAnchors] Array of names of enabled handles
16631
16701
  * @param {Boolean} [config.flipEnabled] Can we flip/mirror shape on transform?. True by default
@@ -16668,6 +16738,8 @@ js: import "konva/skia-backend";
16668
16738
  this._transformWindow = null;
16669
16739
  this._elementsCreated = false;
16670
16740
  this._updateScheduled = false;
16741
+ // an attached container's descendants changed after the last layout
16742
+ this._subtreeChanged = false;
16671
16743
  this._createElements();
16672
16744
  // bindings
16673
16745
  this._handleMouseMove = this._handleMouseMove.bind(this);
@@ -16766,6 +16838,8 @@ js: import "konva/skia-backend";
16766
16838
  }
16767
16839
  node.on(TRANSFORM_CHANGE_STR.map((e) => e + `.${this._getEventNamespace()}`).join(' '), onChange);
16768
16840
  node.on(`absoluteTransformChange.${this._getEventNamespace()}`, onChange);
16841
+ if (node instanceof Container)
16842
+ node._addSubtreeObserver(this);
16769
16843
  node.on(`destroy.${this._getEventNamespace()}`, () => {
16770
16844
  // a destroyed node has nothing left to transform
16771
16845
  this.setNodes(this._nodes.filter((n) => n !== node));
@@ -16842,6 +16916,7 @@ js: import "konva/skia-backend";
16842
16916
  if (this._nodes) {
16843
16917
  this._nodes.forEach((node) => {
16844
16918
  node.off('.' + this._getEventNamespace());
16919
+ node._removeSubtreeObserver(this);
16845
16920
  });
16846
16921
  }
16847
16922
  this._nodes = [];
@@ -16871,6 +16946,42 @@ js: import "konva/skia-backend";
16871
16946
  this._clearCache('transform');
16872
16947
  this._clearSelfAndDescendantCache('absoluteTransform');
16873
16948
  }
16949
+ // Called for every change below an attached container. A burst of child
16950
+ // changes only drops cached values here. The new bounds are measured once,
16951
+ // before the next frame, or earlier if a draw or transform step comes first
16952
+ // (_syncSubtreeChange).
16953
+ _onSubtreeChange(node) {
16954
+ var _a, _b;
16955
+ if (this._fitting)
16956
+ return;
16957
+ // nothing was measured since the last change, so nothing cached is stale
16958
+ if (this._subtreeChanged && !this._cache[NODES_RECT])
16959
+ return;
16960
+ this._resetTransformCache(node);
16961
+ if (!this._subtreeChanged) {
16962
+ this._subtreeChanged = true;
16963
+ // queued ahead of the draw the change requests, so that draw shows the
16964
+ // new layout. Updating inside the draw would request one more frame.
16965
+ Util.requestAnimFrame(() => this._syncSubtreeChange(), (_a = this.getStage()) === null || _a === void 0 ? void 0 : _a._getOwnerWindow());
16966
+ // the transformer can be on another layer than the changed node
16967
+ (_b = this.getLayer()) === null || _b === void 0 ? void 0 : _b.batchDraw();
16968
+ }
16969
+ }
16970
+ _syncSubtreeChange() {
16971
+ var _a;
16972
+ // while dragging, the dragmove handler updates the layout
16973
+ if (this._subtreeChanged && ((_a = this._nodes) === null || _a === void 0 ? void 0 : _a.length) && !this.isDragging()) {
16974
+ this._update();
16975
+ }
16976
+ }
16977
+ drawScene(can, top) {
16978
+ this._syncSubtreeChange();
16979
+ return super.drawScene(can, top);
16980
+ }
16981
+ drawHit(can, top) {
16982
+ this._syncSubtreeChange();
16983
+ return super.drawHit(can, top);
16984
+ }
16874
16985
  _getNodeRect() {
16875
16986
  return this._getCache(NODES_RECT, this.__getNodeRect);
16876
16987
  }
@@ -16985,18 +17096,27 @@ js: import "konva/skia-backend";
16985
17096
  }
16986
17097
  _createElements() {
16987
17098
  this._createBack();
17099
+ // below the resize anchors, so a resize anchor wins where they overlap
17100
+ ROTATE_ZONE_NAMES.forEach((name) => {
17101
+ // invisible, but its fill keeps it in the hit graph
17102
+ this._createAnchor(name, '_rotate-zone').setAttrs({
17103
+ fill: 'transparent',
17104
+ strokeEnabled: false,
17105
+ visible: false,
17106
+ });
17107
+ });
16988
17108
  ANCHORS_NAMES.forEach((name) => {
16989
17109
  this._createAnchor(name);
16990
17110
  });
16991
17111
  this._createAnchor('rotater');
16992
17112
  this._elementsCreated = true;
16993
17113
  }
16994
- _createAnchor(name) {
17114
+ _createAnchor(name, className = '_anchor') {
16995
17115
  const anchor = new Rect({
16996
17116
  stroke: 'rgb(0, 161, 255)',
16997
17117
  fill: 'white',
16998
17118
  strokeWidth: 1,
16999
- name: name + ' _anchor',
17119
+ name: name + ' ' + className,
17000
17120
  dragDistance: 0,
17001
17121
  // make it draggable,
17002
17122
  // so activating the anchor will not start drag&drop of any parent
@@ -17019,11 +17139,7 @@ js: import "konva/skia-backend";
17019
17139
  anchor.on('mouseenter', () => {
17020
17140
  if (this.isTransforming())
17021
17141
  return;
17022
- const rad = Konva$2.getAngle(this.rotation());
17023
- const rotateCursor = this.rotateAnchorCursor();
17024
- const cursor = getCursor(name, rad, rotateCursor);
17025
- anchor.getStage().content &&
17026
- (anchor.getStage().content.style.cursor = cursor);
17142
+ this._setAnchorCursor(name);
17027
17143
  this._cursorChange = true;
17028
17144
  });
17029
17145
  anchor.on('mouseout', () => {
@@ -17034,6 +17150,14 @@ js: import "konva/skia-backend";
17034
17150
  (anchor.getStage().content.style.cursor = '');
17035
17151
  });
17036
17152
  this.add(anchor);
17153
+ return anchor;
17154
+ }
17155
+ _setAnchorCursor(name, rad = Konva$2.getAngle(this.rotation())) {
17156
+ var _a;
17157
+ const content = (_a = this.getStage()) === null || _a === void 0 ? void 0 : _a.content;
17158
+ if (content) {
17159
+ content.style.cursor = getCursor(name, rad, this.rotateAnchorCursor());
17160
+ }
17037
17161
  }
17038
17162
  _createBack() {
17039
17163
  const back = new Shape({
@@ -17049,7 +17173,9 @@ js: import "konva/skia-backend";
17049
17173
  const height = shape.height();
17050
17174
  ctx.beginPath();
17051
17175
  ctx.rect(-padding, -padding, width + padding * 2, height + padding * 2);
17052
- if (tr.rotateEnabled() && tr.rotateLineVisible()) {
17176
+ if (tr.rotateEnabled() &&
17177
+ tr.rotateLineVisible() &&
17178
+ tr.rotateMode() !== 'corners') {
17053
17179
  const line = getRotaterLine(tr, width, height);
17054
17180
  ctx.moveTo(line.edgeX, line.edgeY);
17055
17181
  ctx.lineTo(line.endX, line.endY);
@@ -17121,6 +17247,13 @@ js: import "konva/skia-backend";
17121
17247
  x: pos.x - ap.x,
17122
17248
  y: pos.y - ap.y,
17123
17249
  };
17250
+ if (isRotateAnchor(this._movingAnchorName)) {
17251
+ const center = getCenter(attrs);
17252
+ this._rotateStart = {
17253
+ pointerAngle: Math.atan2(pos.y - center.y, pos.x - center.x),
17254
+ rotation: attrs.rotation,
17255
+ };
17256
+ }
17124
17257
  activeTransformers.add(this);
17125
17258
  this._fire('transformstart', { evt: e.evt, target: this.getNode() });
17126
17259
  this._nodes.forEach((target) => {
@@ -17132,6 +17265,8 @@ js: import "konva/skia-backend";
17132
17265
  (_a = this.getStage()) === null || _a === void 0 ? void 0 : _a._batchEvents(() => this._moveTransform(e));
17133
17266
  }
17134
17267
  _moveTransform(e) {
17268
+ // anchors must show the current bounds before they are measured against
17269
+ this._syncSubtreeChange();
17135
17270
  let x, y, newHypotenuse;
17136
17271
  const anchorNode = this._anchors[this._movingAnchorName];
17137
17272
  const stage = anchorNode.getStage();
@@ -17154,19 +17289,33 @@ js: import "konva/skia-backend";
17154
17289
  if (oldAbs.x === newAbs.x && oldAbs.y === newAbs.y) {
17155
17290
  return;
17156
17291
  }
17157
- // rotater is working very differently, so do it first
17158
- if (this._movingAnchorName === 'rotater') {
17292
+ // rotation is working very differently, so do it first
17293
+ if (isRotateAnchor(this._movingAnchorName)) {
17159
17294
  const attrs = this._getNodeRect();
17160
- x = anchorNode.x() - attrs.width / 2;
17161
- y = -anchorNode.y() + attrs.height / 2;
17162
- // Calculate angle from center to current anchor position
17163
- // Offset by rotateAnchorAngle so we measure rotation from the anchor's starting position
17164
- const rotateAnchorAngleRad = Util.degToRad(this.rotateAnchorAngle());
17165
- let delta = Math.atan2(-y, x) + Math.PI / 2 - rotateAnchorAngleRad;
17166
- const oldRotation = Konva$2.getAngle(this.rotation());
17167
- const newRotation = oldRotation + delta;
17168
- const tol = Konva$2.getAngle(this.rotationSnapTolerance());
17169
- const snappedRot = getSnap(this.rotationSnaps(), newRotation, tol);
17295
+ const center = getCenter(attrs);
17296
+ const start = this._rotateStart;
17297
+ // the grabbed point turns around the center by as much as the box,
17298
+ // so the box follows the pointer wherever it was grabbed
17299
+ const point = {
17300
+ x: newAbs.x + this._anchorDragOffset.x,
17301
+ y: newAbs.y + this._anchorDragOffset.y,
17302
+ };
17303
+ const pointerAngle = Math.atan2(point.y - center.y, point.x - center.x);
17304
+ const newRotation = start.rotation + pointerAngle - start.pointerAngle;
17305
+ let snappedRot;
17306
+ if (e.shiftKey && this.shiftBehavior() !== 'none') {
17307
+ snappedRot =
17308
+ Math.round(newRotation / SHIFT_ROTATION_STEP) * SHIFT_ROTATION_STEP;
17309
+ }
17310
+ else {
17311
+ const tol = Konva$2.getAngle(this.rotationSnapTolerance());
17312
+ snappedRot = getSnap(this.rotationSnaps(), newRotation, tol);
17313
+ }
17314
+ // a corner zone cursor shows the direction of the turned corner,
17315
+ // set before the transform event so its handlers can override it
17316
+ if (this._movingAnchorName !== 'rotater') {
17317
+ this._setAnchorCursor(this._movingAnchorName, snappedRot);
17318
+ }
17170
17319
  const diff = snappedRot - attrs.rotation;
17171
17320
  const shape = rotateAroundCenter(attrs, diff);
17172
17321
  this._fitNodesInto(shape, e);
@@ -17569,7 +17718,9 @@ js: import "konva/skia-backend";
17569
17718
  }
17570
17719
  /**
17571
17720
  * force update of Konva.Transformer.
17572
- * Use it when you updated attached Konva.Group and now you need to reset transformer size
17721
+ * The transformer follows attribute changes of attached nodes and, for an attached group, any change of its descendants.
17722
+ * Use it after a change that sets no attribute, for example a `Line` points array mutated in place
17723
+ * or a custom `getSelfRect()` that depends on outside state.
17573
17724
  * @method
17574
17725
  * @name Konva.Transformer#forceUpdate
17575
17726
  */
@@ -17585,6 +17736,7 @@ js: import "konva/skia-backend";
17585
17736
  }
17586
17737
  _update() {
17587
17738
  var _a;
17739
+ this._subtreeChanged = false;
17588
17740
  const attrs = this._getNodeRect();
17589
17741
  this._updateElements(attrs);
17590
17742
  const draggable = this.nodes().some((node) => node.draggable());
@@ -17593,7 +17745,7 @@ js: import "konva/skia-backend";
17593
17745
  }
17594
17746
  const styleFunc = this.anchorStyleFunc();
17595
17747
  if (styleFunc) {
17596
- Object.values(this._anchors).forEach((node) => styleFunc(node));
17748
+ Object.values(this._anchors).forEach((node) => node.hasName('_anchor') && styleFunc(node));
17597
17749
  }
17598
17750
  (_a = this.getLayer()) === null || _a === void 0 ? void 0 : _a.batchDraw();
17599
17751
  }
@@ -17617,7 +17769,7 @@ js: import "konva/skia-backend";
17617
17769
  const resizeEnabled = this.resizeEnabled();
17618
17770
  const padding = this.padding();
17619
17771
  const anchorSize = this.anchorSize();
17620
- const anchors = Object.values(this._anchors);
17772
+ const anchors = Object.values(this._anchors).filter((node) => node.hasName('_anchor'));
17621
17773
  anchors.forEach((node) => {
17622
17774
  node.setAttrs({
17623
17775
  width: anchorSize,
@@ -17682,11 +17834,25 @@ js: import "konva/skia-backend";
17682
17834
  offsetY: anchorSize / 2 - padding,
17683
17835
  visible: resizeEnabled && enabledAnchors.indexOf('bottom-right') >= 0,
17684
17836
  });
17837
+ const rotateMode = this.rotateMode();
17685
17838
  const rotaterLine = getRotaterLine(this, width, height);
17686
17839
  this._anchors['rotater'].setAttrs({
17687
17840
  x: rotaterLine.endX,
17688
17841
  y: rotaterLine.endY,
17689
- visible: this.rotateEnabled(),
17842
+ visible: this.rotateEnabled() && rotateMode !== 'corners',
17843
+ });
17844
+ // each zone is a square that touches its corner from the outside
17845
+ const zoneSize = anchorSize * 2;
17846
+ const zonesVisible = this.rotateEnabled() && rotateMode !== 'handle';
17847
+ const near = -padding - zoneSize;
17848
+ ROTATE_ZONE_NAMES.forEach((name) => {
17849
+ this._anchors[name].setAttrs({
17850
+ x: name.includes('left') ? near : width + padding,
17851
+ y: name.includes('top') ? near : height + padding,
17852
+ width: zoneSize,
17853
+ height: zoneSize,
17854
+ visible: zonesVisible,
17855
+ });
17690
17856
  });
17691
17857
  this._back.setAttrs({
17692
17858
  width: width,
@@ -17925,6 +18091,23 @@ js: import "konva/skia-backend";
17925
18091
  * transformer.rotateAnchorCursor('grab');
17926
18092
  */
17927
18093
  Factory.addGetterSetter(Transformer, 'rotateAnchorCursor', 'crosshair');
18094
+ /**
18095
+ * get/set how the user rotates the nodes. 'handle' shows the rotate anchor,
18096
+ * 'corners' makes invisible zones just outside the box corners rotate,
18097
+ * 'both' enables both. Hold Shift while rotating to snap to 15 degree steps, unless shiftBehavior is 'none'.
18098
+ * While a corner zone rotates, `getActiveAnchor()` returns its name, such as 'rotater-top-left'.
18099
+ * @name Konva.Transformer#rotateMode
18100
+ * @method
18101
+ * @param {String} mode
18102
+ * @returns {String}
18103
+ * @example
18104
+ * // get
18105
+ * var rotateMode = transformer.rotateMode();
18106
+ *
18107
+ * // set
18108
+ * transformer.rotateMode('corners');
18109
+ */
18110
+ Factory.addGetterSetter(Transformer, 'rotateMode', 'handle');
17928
18111
  /**
17929
18112
  * get/set distance for rotation tolerance
17930
18113
  * @name Konva.Transformer#rotationSnapTolerance