@leafer/core 1.9.2 → 1.9.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/lib/core.cjs CHANGED
@@ -56,7 +56,7 @@ function isUndefined(value) {
56
56
  }
57
57
 
58
58
  function isNull(value) {
59
- return value === undefined || value === null;
59
+ return value == null;
60
60
  }
61
61
 
62
62
  function isString(value) {
@@ -306,6 +306,9 @@ const MathHelper = {
306
306
  num = round$3(num * a) / a;
307
307
  return num === -0 ? 0 : num;
308
308
  },
309
+ sign(num) {
310
+ return num < 0 ? -1 : 1;
311
+ },
309
312
  getScaleData(scale, size, originSize, scaleData) {
310
313
  if (!scaleData) scaleData = {};
311
314
  if (size) {
@@ -1193,10 +1196,8 @@ const BoundsHelper = {
1193
1196
  t.y += y;
1194
1197
  },
1195
1198
  scroll(t, data) {
1196
- if (data.scrollY || data.scrollX) {
1197
- t.x += data.scrollX;
1198
- t.y += data.scrollY;
1199
- }
1199
+ t.x += data.scrollX;
1200
+ t.y += data.scrollY;
1200
1201
  },
1201
1202
  getByMove(t, x, y) {
1202
1203
  t = Object.assign({}, t);
@@ -4106,7 +4107,7 @@ function createDescriptor(key, defaultValue) {
4106
4107
  return {
4107
4108
  get() {
4108
4109
  const v = this[privateKey];
4109
- return isUndefined(v) ? defaultValue : v;
4110
+ return v == null ? defaultValue : v;
4110
4111
  },
4111
4112
  set(value) {
4112
4113
  this[privateKey] = value;
@@ -4392,21 +4393,21 @@ function defineDataProcessor(target, key, defaultValue) {
4392
4393
  };
4393
4394
  } else if (typeof defaultValue === "function") {
4394
4395
  property.get = function() {
4395
- let v = this[computedKey];
4396
- return v === undefined ? defaultValue(this.__leaf) : v;
4396
+ const v = this[computedKey];
4397
+ return v == null ? defaultValue(this.__leaf) : v;
4397
4398
  };
4398
4399
  } else if (isObject(defaultValue)) {
4399
4400
  const isEmpty = isEmptyData(defaultValue);
4400
4401
  property.get = function() {
4401
- let v = this[computedKey];
4402
- return v === undefined ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4402
+ const v = this[computedKey];
4403
+ return v == null ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4403
4404
  };
4404
4405
  }
4405
4406
  const isBox = target.isBranchLeaf;
4406
4407
  if (key === "width") {
4407
4408
  property.get = function() {
4408
4409
  const v = this[computedKey];
4409
- if (v === undefined) {
4410
+ if (v == null) {
4410
4411
  const t = this, naturalWidth = t.__naturalWidth, leaf = t.__leaf;
4411
4412
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.width;
4412
4413
  if (naturalWidth) return t._height && t.__useNaturalRatio ? t._height * naturalWidth / t.__naturalHeight : naturalWidth;
@@ -4416,7 +4417,7 @@ function defineDataProcessor(target, key, defaultValue) {
4416
4417
  } else if (key === "height") {
4417
4418
  property.get = function() {
4418
4419
  const v = this[computedKey];
4419
- if (v === undefined) {
4420
+ if (v == null) {
4420
4421
  const t = this, naturalHeight = t.__naturalHeight, leaf = t.__leaf;
4421
4422
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.height;
4422
4423
  if (naturalHeight) return t._width && t.__useNaturalRatio ? t._width * naturalHeight / t.__naturalWidth : naturalHeight;
@@ -5176,7 +5177,7 @@ class LeafLayout {
5176
5177
  }
5177
5178
  boxChange() {
5178
5179
  this.boxChanged = true;
5179
- this.localBoxChanged || this.localBoxChange();
5180
+ this.localBoxChanged ? this.boundsChanged || (this.boundsChanged = true) : this.localBoxChange();
5180
5181
  this.hitCanvasChanged = true;
5181
5182
  }
5182
5183
  localBoxChange() {
@@ -5210,7 +5211,7 @@ class LeafLayout {
5210
5211
  }
5211
5212
  matrixChange() {
5212
5213
  this.matrixChanged = true;
5213
- this.localBoxChanged || this.localBoxChange();
5214
+ this.localBoxChanged ? this.boundsChanged || (this.boundsChanged = true) : this.localBoxChange();
5214
5215
  }
5215
5216
  surfaceChange() {
5216
5217
  this.surfaceChanged = true;
@@ -6276,10 +6277,10 @@ exports.Leaf = class Leaf {
6276
6277
  relative.innerToWorld(world, to, distance);
6277
6278
  world = to ? to : world;
6278
6279
  }
6279
- toInnerPoint(this.worldTransform, world, to, distance);
6280
+ toInnerPoint(this.scrollWorldTransform, world, to, distance);
6280
6281
  }
6281
6282
  innerToWorld(inner, to, distance, relative) {
6282
- toOuterPoint(this.worldTransform, inner, to, distance);
6283
+ toOuterPoint(this.scrollWorldTransform, inner, to, distance);
6283
6284
  if (relative) relative.worldToInner(to ? to : inner, null, distance);
6284
6285
  }
6285
6286
  getBoxPoint(world, relative, distance, change) {
@@ -6743,7 +6744,7 @@ class LeafLevelList {
6743
6744
  }
6744
6745
  }
6745
6746
 
6746
- const version = "1.9.2";
6747
+ const version = "1.9.4";
6747
6748
 
6748
6749
  exports.AlignHelper = AlignHelper;
6749
6750
 
package/lib/core.esm.js CHANGED
@@ -54,7 +54,7 @@ function isUndefined(value) {
54
54
  }
55
55
 
56
56
  function isNull(value) {
57
- return value === undefined || value === null;
57
+ return value == null;
58
58
  }
59
59
 
60
60
  function isString(value) {
@@ -304,6 +304,9 @@ const MathHelper = {
304
304
  num = round$3(num * a) / a;
305
305
  return num === -0 ? 0 : num;
306
306
  },
307
+ sign(num) {
308
+ return num < 0 ? -1 : 1;
309
+ },
307
310
  getScaleData(scale, size, originSize, scaleData) {
308
311
  if (!scaleData) scaleData = {};
309
312
  if (size) {
@@ -1191,10 +1194,8 @@ const BoundsHelper = {
1191
1194
  t.y += y;
1192
1195
  },
1193
1196
  scroll(t, data) {
1194
- if (data.scrollY || data.scrollX) {
1195
- t.x += data.scrollX;
1196
- t.y += data.scrollY;
1197
- }
1197
+ t.x += data.scrollX;
1198
+ t.y += data.scrollY;
1198
1199
  },
1199
1200
  getByMove(t, x, y) {
1200
1201
  t = Object.assign({}, t);
@@ -4104,7 +4105,7 @@ function createDescriptor(key, defaultValue) {
4104
4105
  return {
4105
4106
  get() {
4106
4107
  const v = this[privateKey];
4107
- return isUndefined(v) ? defaultValue : v;
4108
+ return v == null ? defaultValue : v;
4108
4109
  },
4109
4110
  set(value) {
4110
4111
  this[privateKey] = value;
@@ -4390,21 +4391,21 @@ function defineDataProcessor(target, key, defaultValue) {
4390
4391
  };
4391
4392
  } else if (typeof defaultValue === "function") {
4392
4393
  property.get = function() {
4393
- let v = this[computedKey];
4394
- return v === undefined ? defaultValue(this.__leaf) : v;
4394
+ const v = this[computedKey];
4395
+ return v == null ? defaultValue(this.__leaf) : v;
4395
4396
  };
4396
4397
  } else if (isObject(defaultValue)) {
4397
4398
  const isEmpty = isEmptyData(defaultValue);
4398
4399
  property.get = function() {
4399
- let v = this[computedKey];
4400
- return v === undefined ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4400
+ const v = this[computedKey];
4401
+ return v == null ? this[computedKey] = isEmpty ? {} : DataHelper.clone(defaultValue) : v;
4401
4402
  };
4402
4403
  }
4403
4404
  const isBox = target.isBranchLeaf;
4404
4405
  if (key === "width") {
4405
4406
  property.get = function() {
4406
4407
  const v = this[computedKey];
4407
- if (v === undefined) {
4408
+ if (v == null) {
4408
4409
  const t = this, naturalWidth = t.__naturalWidth, leaf = t.__leaf;
4409
4410
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.width;
4410
4411
  if (naturalWidth) return t._height && t.__useNaturalRatio ? t._height * naturalWidth / t.__naturalHeight : naturalWidth;
@@ -4414,7 +4415,7 @@ function defineDataProcessor(target, key, defaultValue) {
4414
4415
  } else if (key === "height") {
4415
4416
  property.get = function() {
4416
4417
  const v = this[computedKey];
4417
- if (v === undefined) {
4418
+ if (v == null) {
4418
4419
  const t = this, naturalHeight = t.__naturalHeight, leaf = t.__leaf;
4419
4420
  if (!defaultValue || leaf.pathInputed) return leaf.boxBounds.height;
4420
4421
  if (naturalHeight) return t._width && t.__useNaturalRatio ? t._width * naturalHeight / t.__naturalWidth : naturalHeight;
@@ -5174,7 +5175,7 @@ class LeafLayout {
5174
5175
  }
5175
5176
  boxChange() {
5176
5177
  this.boxChanged = true;
5177
- this.localBoxChanged || this.localBoxChange();
5178
+ this.localBoxChanged ? this.boundsChanged || (this.boundsChanged = true) : this.localBoxChange();
5178
5179
  this.hitCanvasChanged = true;
5179
5180
  }
5180
5181
  localBoxChange() {
@@ -5208,7 +5209,7 @@ class LeafLayout {
5208
5209
  }
5209
5210
  matrixChange() {
5210
5211
  this.matrixChanged = true;
5211
- this.localBoxChanged || this.localBoxChange();
5212
+ this.localBoxChanged ? this.boundsChanged || (this.boundsChanged = true) : this.localBoxChange();
5212
5213
  }
5213
5214
  surfaceChange() {
5214
5215
  this.surfaceChanged = true;
@@ -6274,10 +6275,10 @@ let Leaf = class Leaf {
6274
6275
  relative.innerToWorld(world, to, distance);
6275
6276
  world = to ? to : world;
6276
6277
  }
6277
- toInnerPoint(this.worldTransform, world, to, distance);
6278
+ toInnerPoint(this.scrollWorldTransform, world, to, distance);
6278
6279
  }
6279
6280
  innerToWorld(inner, to, distance, relative) {
6280
- toOuterPoint(this.worldTransform, inner, to, distance);
6281
+ toOuterPoint(this.scrollWorldTransform, inner, to, distance);
6281
6282
  if (relative) relative.worldToInner(to ? to : inner, null, distance);
6282
6283
  }
6283
6284
  getBoxPoint(world, relative, distance, change) {
@@ -6741,6 +6742,6 @@ class LeafLevelList {
6741
6742
  }
6742
6743
  }
6743
6744
 
6744
- const version = "1.9.2";
6745
+ const version = "1.9.4";
6745
6746
 
6746
6747
  export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, BoundsEvent, BoundsHelper, Branch, BranchHelper, BranchRender, CanvasManager, ChildEvent, Creator, DataHelper, Debug, Direction4, Direction9, EllipseHelper, Event, EventCreator, Eventer, FileHelper, ImageEvent, ImageManager, IncrementId, LayoutEvent, Leaf, LeafBounds, LeafBoundsHelper, LeafData, LeafDataProxy, LeafEventer, LeafHelper, LeafLayout, LeafLevelList, LeafList, LeafMatrix, LeafRender, LeaferCanvasBase, LeaferEvent, LeaferImage, MathHelper, Matrix, MatrixHelper, NeedConvertToCanvasCommandMap, OneRadian, PI2, PI_2, PathBounds, PathCommandDataHelper, PathCommandMap, PathConvert, PathCorner, PathCreator, PathDrawer, PathHelper, PathNumberCommandLengthMap, PathNumberCommandMap, Platform, Plugin, Point, PointHelper, PropertyEvent, RectHelper, RenderEvent, ResizeEvent, Resource, Run, StringNumberMap, TaskItem, TaskProcessor, TwoPointBoundsHelper, UICreator, WaitHelper, WatchEvent, affectRenderBoundsType, affectStrokeBoundsType, attr, autoLayoutType, boundsType, canvasPatch, canvasSizeAttrs, createDescriptor, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, emptyData, eraserType, extraPropertyEventMap, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isArray, isData, isEmptyData, isFinite, isNull, isNumber, isObject, isString, isUndefined, layoutProcessor, leaferTransformAttrMap, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, scrollType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, tryToNumber, useModule, version, visibleType };