@leafer/core 1.6.0 → 1.6.2

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
@@ -2591,7 +2591,11 @@ const BezierHelper = {
2591
2591
  const point = {};
2592
2592
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, point);
2593
2593
  return point;
2594
- }
2594
+ },
2595
+ getDerivative(t, fromV, v1, v2, toV) {
2596
+ const o = 1 - t;
2597
+ return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
2598
+ },
2595
2599
  };
2596
2600
  const { getPointAndSet, toTwoPointBounds: toTwoPointBounds$1, ellipse: ellipse$5 } = BezierHelper;
2597
2601
 
@@ -3772,8 +3776,11 @@ class LeaferImage {
3772
3776
  load(onSuccess, onError) {
3773
3777
  if (!this.loading) {
3774
3778
  this.loading = true;
3779
+ let { loadImage, loadImageWithProgress } = Platform.origin, onProgress = this.config.showProgress && loadImageWithProgress && this.onProgress.bind(this);
3780
+ if (onProgress)
3781
+ loadImage = loadImageWithProgress;
3775
3782
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function* () {
3776
- return yield Platform.origin.loadImage(this.url).then(img => this.setView(img)).catch((e) => {
3783
+ return yield loadImage(this.url, onProgress).then(img => this.setView(img)).catch((e) => {
3777
3784
  this.error = e;
3778
3785
  this.onComplete(false);
3779
3786
  });
@@ -3798,6 +3805,9 @@ class LeaferImage {
3798
3805
  this.view = img;
3799
3806
  this.onComplete(true);
3800
3807
  }
3808
+ onProgress(progress) {
3809
+ this.progress = progress;
3810
+ }
3801
3811
  onComplete(isSuccess) {
3802
3812
  let odd;
3803
3813
  this.waitComplete.forEach((item, index) => {
@@ -4267,9 +4277,16 @@ const LeafHelper = {
4267
4277
  }
4268
4278
  }
4269
4279
  },
4270
- updateAllChange(leaf) {
4271
- updateAllWorldOpacity(leaf);
4280
+ updateChange(leaf) {
4281
+ const layout = leaf.__layout;
4282
+ if (layout.stateStyleChanged)
4283
+ leaf.updateState();
4284
+ if (layout.opacityChanged)
4285
+ updateAllWorldOpacity(leaf);
4272
4286
  leaf.__updateChange();
4287
+ },
4288
+ updateAllChange(leaf) {
4289
+ updateChange(leaf);
4273
4290
  if (leaf.isBranch) {
4274
4291
  const { children } = leaf;
4275
4292
  for (let i = 0, len = children.length; i < len; i++) {
@@ -4405,7 +4422,7 @@ const LeafHelper = {
4405
4422
  }
4406
4423
  };
4407
4424
  const L = LeafHelper;
4408
- const { updateAllMatrix: updateAllMatrix$1, updateMatrix: updateMatrix$1, updateAllWorldOpacity, updateAllChange } = L;
4425
+ const { updateAllMatrix: updateAllMatrix$1, updateMatrix: updateMatrix$1, updateAllWorldOpacity, updateAllChange, updateChange } = L;
4409
4426
  function getTempLocal(t, world) {
4410
4427
  t.__layout.update();
4411
4428
  return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
@@ -6127,7 +6144,7 @@ class LeafLevelList {
6127
6144
  }
6128
6145
  }
6129
6146
 
6130
- const version = "1.6.0";
6147
+ const version = "1.6.2";
6131
6148
 
6132
6149
  exports.AlignHelper = AlignHelper;
6133
6150
  exports.AroundHelper = AroundHelper;
@@ -6247,4 +6264,3 @@ exports.tempPoint = tempPoint$2;
6247
6264
  exports.useModule = useModule;
6248
6265
  exports.version = version;
6249
6266
  exports.visibleType = visibleType;
6250
- //# sourceMappingURL=core.cjs.map
package/lib/core.esm.js CHANGED
@@ -2589,7 +2589,11 @@ const BezierHelper = {
2589
2589
  const point = {};
2590
2590
  getPointAndSet(t, fromX, fromY, x1, y1, x2, y2, toX, toY, point);
2591
2591
  return point;
2592
- }
2592
+ },
2593
+ getDerivative(t, fromV, v1, v2, toV) {
2594
+ const o = 1 - t;
2595
+ return 3 * o * o * (v1 - fromV) + 6 * o * t * (v2 - v1) + 3 * t * t * (toV - v2);
2596
+ },
2593
2597
  };
2594
2598
  const { getPointAndSet, toTwoPointBounds: toTwoPointBounds$1, ellipse: ellipse$5 } = BezierHelper;
2595
2599
 
@@ -3770,8 +3774,11 @@ class LeaferImage {
3770
3774
  load(onSuccess, onError) {
3771
3775
  if (!this.loading) {
3772
3776
  this.loading = true;
3777
+ let { loadImage, loadImageWithProgress } = Platform.origin, onProgress = this.config.showProgress && loadImageWithProgress && this.onProgress.bind(this);
3778
+ if (onProgress)
3779
+ loadImage = loadImageWithProgress;
3773
3780
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function* () {
3774
- return yield Platform.origin.loadImage(this.url).then(img => this.setView(img)).catch((e) => {
3781
+ return yield loadImage(this.url, onProgress).then(img => this.setView(img)).catch((e) => {
3775
3782
  this.error = e;
3776
3783
  this.onComplete(false);
3777
3784
  });
@@ -3796,6 +3803,9 @@ class LeaferImage {
3796
3803
  this.view = img;
3797
3804
  this.onComplete(true);
3798
3805
  }
3806
+ onProgress(progress) {
3807
+ this.progress = progress;
3808
+ }
3799
3809
  onComplete(isSuccess) {
3800
3810
  let odd;
3801
3811
  this.waitComplete.forEach((item, index) => {
@@ -4265,9 +4275,16 @@ const LeafHelper = {
4265
4275
  }
4266
4276
  }
4267
4277
  },
4268
- updateAllChange(leaf) {
4269
- updateAllWorldOpacity(leaf);
4278
+ updateChange(leaf) {
4279
+ const layout = leaf.__layout;
4280
+ if (layout.stateStyleChanged)
4281
+ leaf.updateState();
4282
+ if (layout.opacityChanged)
4283
+ updateAllWorldOpacity(leaf);
4270
4284
  leaf.__updateChange();
4285
+ },
4286
+ updateAllChange(leaf) {
4287
+ updateChange(leaf);
4271
4288
  if (leaf.isBranch) {
4272
4289
  const { children } = leaf;
4273
4290
  for (let i = 0, len = children.length; i < len; i++) {
@@ -4403,7 +4420,7 @@ const LeafHelper = {
4403
4420
  }
4404
4421
  };
4405
4422
  const L = LeafHelper;
4406
- const { updateAllMatrix: updateAllMatrix$1, updateMatrix: updateMatrix$1, updateAllWorldOpacity, updateAllChange } = L;
4423
+ const { updateAllMatrix: updateAllMatrix$1, updateMatrix: updateMatrix$1, updateAllWorldOpacity, updateAllChange, updateChange } = L;
4407
4424
  function getTempLocal(t, world) {
4408
4425
  t.__layout.update();
4409
4426
  return t.parent ? PointHelper.tempToInnerOf(world, t.parent.__world) : world;
@@ -6125,7 +6142,6 @@ class LeafLevelList {
6125
6142
  }
6126
6143
  }
6127
6144
 
6128
- const version = "1.6.0";
6145
+ const version = "1.6.2";
6129
6146
 
6130
6147
  export { AlignHelper, Answer, AroundHelper, AutoBounds, BezierHelper, Bounds, 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, cursorType, dataProcessor, dataType, decorateLeafAttr, defineDataProcessor, defineKey, defineLeafAttr, doBoundsType, doStrokeType, emptyData, eraserType, getBoundsData, getDescriptor, getMatrixData, getPointData, hitType, isEmptyData, isNull, layoutProcessor, maskType, naturalBoundsType, opacityType, pathInputType, pathType, pen, positionType, registerUI, registerUIEvent, rewrite, rewriteAble, rotationType, scaleType, sortType, strokeType, surfaceType, tempBounds, tempMatrix, tempPoint$2 as tempPoint, useModule, version, visibleType };
6131
- //# sourceMappingURL=core.esm.js.map