leafer-ui 1.0.0-rc.18 → 1.0.0-rc.19

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.
@@ -6476,7 +6476,7 @@ class Picker {
6476
6476
  return path;
6477
6477
  }
6478
6478
  getHitablePath(leaf) {
6479
- const path = this.getPath(leaf);
6479
+ const path = this.getPath(leaf && leaf.hittable ? leaf : null);
6480
6480
  let item, hittablePath = new LeafList();
6481
6481
  for (let i = path.list.length - 1; i > -1; i--) {
6482
6482
  item = path.list[i];
@@ -7519,7 +7519,7 @@ let Leafer = class Leafer extends Group {
7519
7519
  hittable: true,
7520
7520
  smooth: true,
7521
7521
  zoom: {
7522
- min: 0.02,
7522
+ min: 0.01,
7523
7523
  max: 256
7524
7524
  },
7525
7525
  move: {
@@ -9077,7 +9077,7 @@ class Dragger {
9077
9077
  return;
9078
9078
  }
9079
9079
  if (!this.moving && canDrag) {
9080
- if (this.moving = interaction.moveMode || interaction.isHoldRightKey)
9080
+ if (this.moving = interaction.canMove(this.downData) || interaction.isHoldRightKey)
9081
9081
  interaction.emit(MoveEvent.START, this.dragData);
9082
9082
  }
9083
9083
  if (!this.moving) {
@@ -9351,7 +9351,7 @@ const config = {
9351
9351
  const { pathHasEventType, getMoveEventData: getMoveEventData$1, getZoomEventData: getZoomEventData$1, getRotateEventData: getRotateEventData$1 } = InteractionHelper;
9352
9352
  class InteractionBase {
9353
9353
  get dragging() { return this.dragger.dragging; }
9354
- get isDragEmpty() { return this.config.move.dragEmpty && (this.hoverData && this.hoverData.path.list[0].isLeafer) && (!this.downData || this.downData.path.list[0].isLeafer); }
9354
+ get isDragEmpty() { return this.config.move.dragEmpty && this.isRootPath(this.hoverData) && (!this.downData || this.isRootPath(this.downData)); }
9355
9355
  get isHoldRightKey() { return this.config.move.holdRightKey && this.downData && PointerButton.right(this.downData); }
9356
9356
  get moveMode() { return this.config.move.drag || (this.config.move.holdSpaceKey && Keyboard.isHoldSpaceKey()) || (this.downData && ((this.config.move.holdMiddleKey && PointerButton.middle(this.downData)) || (this.isHoldRightKey && this.dragger.moving))) || this.isDragEmpty; }
9357
9357
  get hitRadius() { return this.config.pointer.hitRadius; }
@@ -9383,19 +9383,16 @@ class InteractionBase {
9383
9383
  return;
9384
9384
  PointerButton.defaultLeft(data);
9385
9385
  this.updateDownData(data);
9386
- if (useDefaultPath)
9387
- data.path = this.defaultPath;
9386
+ this.checkPath(data, useDefaultPath);
9388
9387
  this.downTime = Date.now();
9389
- if (this.downed = !this.moveMode) {
9390
- this.emit(PointerEvent.BEFORE_DOWN, data);
9391
- this.emit(PointerEvent.DOWN, data);
9392
- if (PointerButton.left(data)) {
9393
- this.tapWait();
9394
- this.longPressWait(data);
9395
- }
9396
- else if (PointerButton.right(data)) {
9397
- this.waitMenuTap = true;
9398
- }
9388
+ this.emit(PointerEvent.BEFORE_DOWN, data);
9389
+ this.emit(PointerEvent.DOWN, data);
9390
+ if (PointerButton.left(data)) {
9391
+ this.tapWait();
9392
+ this.longPressWait(data);
9393
+ }
9394
+ else if (PointerButton.right(data)) {
9395
+ this.waitMenuTap = true;
9399
9396
  }
9400
9397
  this.dragger.setDragData(data);
9401
9398
  this.updateCursor(data);
@@ -9410,10 +9407,6 @@ class InteractionBase {
9410
9407
  PointerButton.defaultLeft(data);
9411
9408
  const hit = this.canvas.bounds.hitPoint(data);
9412
9409
  if (hit || downData) {
9413
- if (hit && !downData && PointerButton.left(data)) {
9414
- this.pointerDown(data, true);
9415
- this.dragger.canDragOut = false;
9416
- }
9417
9410
  this.pointerMoveReal(data);
9418
9411
  if (downData)
9419
9412
  this.dragger.checkDragOut(data);
@@ -9432,8 +9425,7 @@ class InteractionBase {
9432
9425
  }
9433
9426
  if (!this.dragger.moving) {
9434
9427
  this.updateHoverData(data);
9435
- if (this.moveMode)
9436
- data.path = this.defaultPath;
9428
+ this.checkPath(data);
9437
9429
  this.emit(PointerEvent.MOVE, data);
9438
9430
  if (!(this.dragging && !this.config.pointer.dragHover))
9439
9431
  this.pointerHover(data);
@@ -9445,26 +9437,22 @@ class InteractionBase {
9445
9437
  this.updateCursor(this.downData || data);
9446
9438
  }
9447
9439
  pointerUp(data) {
9448
- const { downData, oldDownData } = this;
9440
+ const { downData } = this;
9449
9441
  if (!data)
9450
9442
  data = downData;
9451
9443
  if (!downData)
9452
9444
  return;
9453
9445
  PointerButton.defaultLeft(data);
9446
+ this.downData = null;
9454
9447
  this.findPath(data);
9455
- if (this.downed) {
9456
- this.downed = false;
9457
- this.emit(PointerEvent.BEFORE_UP, data);
9458
- this.emit(PointerEvent.UP, data);
9459
- if (oldDownData)
9460
- this.emit(PointerEvent.UP, oldDownData, undefined, data.path);
9461
- this.emit(PointerEvent.UP, downData, undefined, data.path);
9462
- this.touchLeave(data);
9463
- this.tap(data);
9464
- this.menuTap(data);
9465
- }
9448
+ data.path.addList(downData.path.list);
9449
+ this.checkPath(data);
9450
+ this.emit(PointerEvent.BEFORE_UP, data);
9451
+ this.emit(PointerEvent.UP, data);
9452
+ this.touchLeave(data);
9453
+ this.tap(data);
9454
+ this.menuTap(data);
9466
9455
  this.dragger.dragEnd(data);
9467
- this.downData = this.oldDownData = null;
9468
9456
  this.updateCursor(data);
9469
9457
  }
9470
9458
  pointerCancel() {
@@ -9597,12 +9585,21 @@ class InteractionBase {
9597
9585
  data.path = find.path;
9598
9586
  return find.path;
9599
9587
  }
9588
+ isRootPath(data) {
9589
+ return data && data.path.list[0].isLeafer;
9590
+ }
9591
+ checkPath(data, useDefaultPath) {
9592
+ if (useDefaultPath || this.canMove(data))
9593
+ data.path = this.defaultPath;
9594
+ }
9595
+ canMove(data) {
9596
+ return this.moveMode && data && data.path.list.every(item => !item.isOutside);
9597
+ }
9600
9598
  isDrag(leaf) {
9601
9599
  return this.dragger.getList().has(leaf);
9602
9600
  }
9603
9601
  isPress(leaf) {
9604
- const { downData, oldDownData } = this;
9605
- return this.downed && ((downData && downData.path.has(leaf)) || (oldDownData && oldDownData.path.has(leaf)));
9602
+ return this.downData && this.downData.path.has(leaf);
9606
9603
  }
9607
9604
  isHover(leaf) {
9608
9605
  return this.enterPath && this.enterPath.has(leaf);
@@ -9617,14 +9614,15 @@ class InteractionBase {
9617
9614
  this.pointerHover(hoverData);
9618
9615
  }
9619
9616
  }
9620
- updateDownData(data, options) {
9617
+ updateDownData(data, options, merge) {
9621
9618
  const { downData } = this;
9622
9619
  if (!data && downData)
9623
- data = Object.assign({}, downData);
9620
+ data = downData;
9624
9621
  if (!data)
9625
9622
  return;
9626
- this.oldDownData = downData;
9627
9623
  this.findPath(data, options);
9624
+ if (merge && downData)
9625
+ data.path.addList(downData.path.list);
9628
9626
  this.downData = data;
9629
9627
  }
9630
9628
  updateHoverData(data) {
@@ -9645,7 +9643,7 @@ class InteractionBase {
9645
9643
  if (this.dragger.moving) {
9646
9644
  return this.setCursor('grabbing');
9647
9645
  }
9648
- else if (this.moveMode) {
9646
+ else if (this.canMove(data)) {
9649
9647
  return this.setCursor(this.downData ? 'grabbing' : 'grab');
9650
9648
  }
9651
9649
  else if (!data)
@@ -9785,7 +9783,8 @@ const inner = {};
9785
9783
  Leaf.prototype.__hitWorld = function (point) {
9786
9784
  if (this.__layout.hitCanvasChanged || !this.__hitCanvas) {
9787
9785
  this.__updateHitCanvas();
9788
- this.__layout.hitCanvasChanged = false;
9786
+ if (!this.__layout.boundsChanged)
9787
+ this.__layout.hitCanvasChanged = false;
9789
9788
  }
9790
9789
  if (this.__.hitRadius) {
9791
9790
  copy$2(inner, point), point = inner;