leafer-game 2.2.0 → 2.2.1

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/dist/web.js CHANGED
@@ -4261,10 +4261,13 @@ var LeaferUI = function(exports) {
4261
4261
  function surfaceType(defaultValue) {
4262
4262
  return decorateLeafAttr(defaultValue, key => attr({
4263
4263
  set(value) {
4264
- this.__setAttr(key, value) && (this.__layout.surfaceChanged || this.__layout.surfaceChange());
4264
+ this.__setAttr(key, value) && doSurfaceType(this);
4265
4265
  }
4266
4266
  }));
4267
4267
  }
4268
+ function doSurfaceType(leaf) {
4269
+ leaf.__layout.surfaceChanged || leaf.__layout.surfaceChange();
4270
+ }
4268
4271
  function dimType(defaultValue) {
4269
4272
  return decorateLeafAttr(defaultValue, key => attr({
4270
4273
  set(value) {
@@ -4324,12 +4327,12 @@ var LeaferUI = function(exports) {
4324
4327
  }
4325
4328
  }));
4326
4329
  }
4327
- function maskType(defaultValue) {
4330
+ function maskType(defaultValue, updateSelf) {
4328
4331
  return decorateLeafAttr(defaultValue, key => attr({
4329
4332
  set(value) {
4330
4333
  if (this.__setAttr(key, value)) {
4331
4334
  this.__layout.boxChanged || this.__layout.boxChange();
4332
- this.waitParent(() => {
4335
+ updateSelf ? this.__updateMask() : this.waitParent(() => {
4333
4336
  this.parent.__updateMask(value);
4334
4337
  });
4335
4338
  }
@@ -5860,7 +5863,8 @@ var LeaferUI = function(exports) {
5860
5863
  if (this.__worldOpacity && hasSize(nowWorld)) {
5861
5864
  const data = this.__;
5862
5865
  if (data.__useDim) {
5863
- if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.bright && !options.topRendering) return options.topList.add(this); else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5866
+ if (data.bright && !options.topRendering) return options.topList.add(this);
5867
+ if (data.dim) options.dimOpacity = data.dim === true ? .2 : data.dim; else if (data.dimskip) options.dimOpacity && (options.dimOpacity = 0);
5864
5868
  }
5865
5869
  if (data.__single && !this.isBranchLeaf) {
5866
5870
  if (data.eraser === "path") return this.__renderEraser(canvas, options);
@@ -5884,6 +5888,7 @@ var LeaferUI = function(exports) {
5884
5888
  child = children[i];
5885
5889
  excludeRenderBounds$1(child, options) || (child.__hasComplex ? LeafHelper.renderComplex(child, canvas, options) : child.__render(canvas, options));
5886
5890
  }
5891
+ if (this.__hasMask === 0) this.__rerenderMask(canvas, options);
5887
5892
  }
5888
5893
  },
5889
5894
  __clip(canvas, options) {
@@ -6092,11 +6097,19 @@ var LeaferUI = function(exports) {
6092
6097
  updateLayout() {
6093
6098
  this.__layout.update();
6094
6099
  }
6095
- forceUpdate(attrName) {
6096
- if (isUndefined(attrName)) attrName = "width"; else if (attrName === "surface") attrName = "blendMode";
6097
- const value = this.__.__getInput(attrName);
6098
- this.__[attrName] = isUndefined(value) ? null : undefined;
6099
- this[attrName] = value;
6100
+ forceUpdate(typeOrAttrName) {
6101
+ let quick;
6102
+ if (!typeOrAttrName || typeOrAttrName === "bounds") doBoundsType(this), quick = true; else if (typeOrAttrName === "surface") doSurfaceType(this),
6103
+ quick = true; else if (typeOrAttrName === "stroke") doStrokeType(this), quick = true;
6104
+ if (quick) {
6105
+ const {leafer: leafer} = this;
6106
+ return leafer && leafer.watcher && leafer.watcher.__onAttrChange({
6107
+ target: this
6108
+ });
6109
+ }
6110
+ const value = this.__.__getInput(typeOrAttrName);
6111
+ this.__[typeOrAttrName] = isUndefined(value) ? null : undefined;
6112
+ this[typeOrAttrName] = value;
6100
6113
  }
6101
6114
  forceRender(_bounds, _sync) {
6102
6115
  this.forceUpdate("surface");
@@ -6115,7 +6128,8 @@ var LeaferUI = function(exports) {
6115
6128
  canvas.restore();
6116
6129
  }
6117
6130
  __updateMask(_value) {
6118
- this.__hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6131
+ const hasMask = this.children.some(item => item.__.mask && item.__.visible && item.__.opacity);
6132
+ this.__hasMask = this.__.maskskip ? hasMask && 0 : hasMask;
6119
6133
  }
6120
6134
  __getNowWorld(options) {
6121
6135
  if (options.matrix) {
@@ -6574,7 +6588,7 @@ var LeaferUI = function(exports) {
6574
6588
  this.levelMap = null;
6575
6589
  }
6576
6590
  }
6577
- const version = "2.2.0";
6591
+ const version = "2.2.1";
6578
6592
  const debug$5 = Debug.get("LeaferCanvas");
6579
6593
  class LeaferCanvas extends LeaferCanvasBase {
6580
6594
  set zIndex(zIndex) {
@@ -7455,7 +7469,7 @@ var LeaferUI = function(exports) {
7455
7469
  for (let i = 0, len = list.length; i < len; i++) {
7456
7470
  find = list[i];
7457
7471
  if (ignoreHittable || LeafHelper.worldHittable(find)) {
7458
- this.hitChild(find, point);
7472
+ this.hitChild(find, find.hitThrough ? this.point : point);
7459
7473
  if (findList.length) {
7460
7474
  if (find.isBranchLeaf && list.some(item => item !== find && LeafHelper.hasParent(item, find))) {
7461
7475
  findList.reset();
@@ -7468,7 +7482,7 @@ var LeaferUI = function(exports) {
7468
7482
  }
7469
7483
  if (bottomList) {
7470
7484
  for (let i = 0, len = bottomList.length; i < len; i++) {
7471
- this.hitChild(bottomList[i].target, this.point, bottomList[i].proxy);
7485
+ this.hitChild(bottomList[i].target, this.point, undefined, bottomList[i].proxy);
7472
7486
  if (findList.length) return findList.list[0];
7473
7487
  }
7474
7488
  }
@@ -7526,42 +7540,38 @@ var LeaferUI = function(exports) {
7526
7540
  hitBranch(branch) {
7527
7541
  this.eachFind(branch.children, branch.__onlyHitMask);
7528
7542
  }
7529
- eachFind(children, hitMask) {
7543
+ eachFind(children, onlyHitMask) {
7530
7544
  let child, hit, data;
7531
7545
  const {point: point} = this, len = children.length;
7532
7546
  for (let i = len - 1; i > -1; i--) {
7533
7547
  child = children[i], data = child.__;
7534
- if (!data.visible || hitMask && !data.mask) continue;
7548
+ if (!data.visible || onlyHitMask && !data.mask) continue;
7535
7549
  hit = hitRadiusPoint$1(child.__world, data.hitRadius ? copyRadiusPoint$1(tempPoint$2, point, data.hitRadius) : point);
7536
7550
  if (child.isBranch) {
7537
7551
  if (hit || child.__ignoreHitWorld) {
7538
7552
  if (child.isBranchLeaf && data.__clipAfterFill && !child.__hitWorld(point, true)) continue;
7539
7553
  if (child.topChildren) this.eachFind(child.topChildren, false);
7540
7554
  this.eachFind(child.children, child.__onlyHitMask);
7541
- if (child.isBranchLeaf) this.hitChild(child, point);
7555
+ if (child.isBranchLeaf) this.hitChild(child, point, onlyHitMask);
7542
7556
  }
7543
7557
  } else {
7544
- if (hit) this.hitChild(child, point);
7558
+ if (hit) this.hitChild(child, point, onlyHitMask);
7545
7559
  }
7546
7560
  }
7547
7561
  }
7548
- hitChild(child, point, proxy) {
7562
+ hitChild(child, point, onlyHitMask, proxy) {
7549
7563
  if (this.exclude && this.exclude.has(child)) return;
7550
- if (child.__hitWorld(point)) {
7551
- const {parent: parent} = child;
7552
- if (parent && parent.__hasMask && !child.__.mask) {
7553
- let findMasks = [], item;
7554
- const {children: children} = parent;
7555
- for (let i = 0, len = children.length; i < len; i++) {
7556
- item = children[i];
7557
- if (item.__.mask) findMasks.push(item);
7558
- if (item === child) {
7559
- if (findMasks && !findMasks.every(value => value.__hitWorld(point))) return;
7560
- break;
7561
- }
7562
- }
7564
+ if (child.__hitWorld(point, onlyHitMask && child.mask === "path" ? true : undefined)) {
7565
+ const {parent: parent, mask: mask} = child;
7566
+ if (parent && parent.__hasMask && mask && !(mask === "clipping" || mask === "clipping-path")) {
7567
+ if (!parent.children.some(item => !item.mask && item.__hitWorld(point))) return;
7568
+ }
7569
+ const leaf = proxy || child, {hitThrough: hitThrough} = child, {findList: findList} = this;
7570
+ if (hitThrough) {
7571
+ const index = findList.list.findIndex(item => item[hitThrough] === child[hitThrough]);
7572
+ if (index > 0) return findList.addAt(leaf, index);
7563
7573
  }
7564
- this.findList.add(proxy || child);
7574
+ findList.add(leaf);
7565
7575
  }
7566
7576
  }
7567
7577
  clear() {
@@ -8328,6 +8338,7 @@ var LeaferUI = function(exports) {
8328
8338
  __decorate([ dataType("auto") ], exports.UI.prototype, "dragBoundsType", void 0);
8329
8339
  __decorate([ dataType(false) ], exports.UI.prototype, "editable", void 0);
8330
8340
  __decorate([ hitType(true) ], exports.UI.prototype, "hittable", void 0);
8341
+ __decorate([ hitType() ], exports.UI.prototype, "hitThrough", void 0);
8331
8342
  __decorate([ hitType("path") ], exports.UI.prototype, "hitFill", void 0);
8332
8343
  __decorate([ strokeType("path") ], exports.UI.prototype, "hitStroke", void 0);
8333
8344
  __decorate([ hitType(false) ], exports.UI.prototype, "hitBox", void 0);
@@ -9917,6 +9928,7 @@ var LeaferUI = function(exports) {
9917
9928
  }
9918
9929
  dragEnd(data) {
9919
9930
  if (!this.dragging && !this.moving) return;
9931
+ setTimeout(() => this.interaction.pointerMove(data));
9920
9932
  if (this.checkDragEndAnimate(data)) return;
9921
9933
  this.dragEndReal(data);
9922
9934
  }
@@ -11443,7 +11455,7 @@ var LeaferUI = function(exports) {
11443
11455
  data.__naturalWidth = image.width / data.pixelRatio;
11444
11456
  data.__naturalHeight = image.height / data.pixelRatio;
11445
11457
  if (data.__autoSide) {
11446
- ui.forceUpdate("width");
11458
+ ui.forceUpdate();
11447
11459
  LeafHelper.updateBounds(ui);
11448
11460
  ui.__layout.boundsChanged = true;
11449
11461
  if (ui.__proxyData) {
@@ -12705,7 +12717,7 @@ var LeaferUI = function(exports) {
12705
12717
  const data = this.__;
12706
12718
  const width = nowFrame.width / data.pixelRatio;
12707
12719
  const height = nowFrame.height / data.pixelRatio;
12708
- if (data.width !== width || data.height !== height) this.forceUpdate("width");
12720
+ if (data.width !== width || data.height !== height) this.forceUpdate();
12709
12721
  data.__naturalWidth = width;
12710
12722
  data.__naturalHeight = height;
12711
12723
  }
@@ -14723,6 +14735,7 @@ var LeaferUI = function(exports) {
14723
14735
  exports.dimType = dimType;
14724
14736
  exports.doBoundsType = doBoundsType;
14725
14737
  exports.doStrokeType = doStrokeType;
14738
+ exports.doSurfaceType = doSurfaceType;
14726
14739
  exports.effectType = effectType;
14727
14740
  exports.emptyData = emptyData;
14728
14741
  exports.eraserType = eraserType;