@leafer-editor/worker 1.12.2 → 1.12.3

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/worker.js CHANGED
@@ -3875,6 +3875,10 @@ var LeaferUI = function(exports) {
3875
3875
  get url() {
3876
3876
  return this.config.url;
3877
3877
  }
3878
+ get crossOrigin() {
3879
+ const {crossOrigin: crossOrigin} = this.config;
3880
+ return isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin;
3881
+ }
3878
3882
  get completed() {
3879
3883
  return this.ready || !!this.error;
3880
3884
  }
@@ -3892,12 +3896,14 @@ var LeaferUI = function(exports) {
3892
3896
  ImageManager.isFormat("svg", config) && (this.isSVG = true);
3893
3897
  ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
3894
3898
  }
3895
- load(onSuccess, onError) {
3899
+ load(onSuccess, onError, thumbSize) {
3896
3900
  if (!this.loading) {
3897
3901
  this.loading = true;
3898
- const {crossOrigin: crossOrigin} = this.config;
3899
3902
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
3900
- return yield Platform.origin.loadImage(this.url, isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin, this).then(img => this.setView(img)).catch(e => {
3903
+ return yield Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
3904
+ if (thumbSize) this.setThumbView(img);
3905
+ this.setView(img);
3906
+ }).catch(e => {
3901
3907
  this.error = e;
3902
3908
  this.onComplete(false);
3903
3909
  });
@@ -3918,9 +3924,11 @@ var LeaferUI = function(exports) {
3918
3924
  }
3919
3925
  setView(img) {
3920
3926
  this.ready = true;
3921
- this.width = img.naturalWidth || img.width;
3922
- this.height = img.naturalHeight || img.height;
3923
- this.view = img;
3927
+ if (!this.width) {
3928
+ this.width = img.width;
3929
+ this.height = img.height;
3930
+ this.view = img;
3931
+ }
3924
3932
  this.onComplete(true);
3925
3933
  }
3926
3934
  onComplete(isSuccess) {
@@ -3966,6 +3974,19 @@ var LeaferUI = function(exports) {
3966
3974
  Platform.image.setPatternTransform(pattern, transform, paint);
3967
3975
  return pattern;
3968
3976
  }
3977
+ getLoadUrl(_thumbSize) {
3978
+ return this.url;
3979
+ }
3980
+ setThumbView(_view) {}
3981
+ getThumbSize() {
3982
+ return undefined;
3983
+ }
3984
+ getMinLevel() {
3985
+ return undefined;
3986
+ }
3987
+ getLevelData(_level) {
3988
+ return undefined;
3989
+ }
3969
3990
  clearLevels(_checkUse) {}
3970
3991
  destroy() {
3971
3992
  this.clearLevels();
@@ -6526,7 +6547,7 @@ var LeaferUI = function(exports) {
6526
6547
  this.levelMap = null;
6527
6548
  }
6528
6549
  }
6529
- const version = "1.12.2";
6550
+ const version = "1.12.3";
6530
6551
  class LeaferCanvas extends LeaferCanvasBase {
6531
6552
  get allowBackgroundColor() {
6532
6553
  return true;
@@ -9416,6 +9437,8 @@ var LeaferUI = function(exports) {
9416
9437
  exports.MoveEvent.MOVE = "move";
9417
9438
  exports.MoveEvent.DRAG_ANIMATE = "move.drag_animate";
9418
9439
  exports.MoveEvent.END = "move.end";
9440
+ exports.MoveEvent.PULL_DOWN = "move.pull_down";
9441
+ exports.MoveEvent.REACH_BOTTOM = "move.reach_bottom";
9419
9442
  exports.MoveEvent = __decorate([ registerUIEvent() ], exports.MoveEvent);
9420
9443
  exports.TouchEvent = class TouchEvent extends UIEvent {};
9421
9444
  exports.TouchEvent = __decorate([ registerUIEvent() ], exports.TouchEvent);
@@ -10790,7 +10813,7 @@ var LeaferUI = function(exports) {
10790
10813
  ignoreRender(ui, false);
10791
10814
  onLoadError(ui, event, error);
10792
10815
  leafPaint.loadId = undefined;
10793
- });
10816
+ }, paint.lod && image.getThumbSize());
10794
10817
  if (ui.placeholderColor) {
10795
10818
  if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
10796
10819
  if (!image.ready) {
@@ -14532,15 +14555,27 @@ var LeaferUI = function(exports) {
14532
14555
  exports.UI.setEditInner = function(editorName) {
14533
14556
  this.changeAttr("editInner", editorName);
14534
14557
  };
14558
+ function getScrollType(leafer) {
14559
+ const {scroll: scroll, disabled: disabled} = leafer.app.config.move;
14560
+ return !scroll || disabled ? "" : scroll === true ? "free" : scroll;
14561
+ }
14535
14562
  function addViewport(leafer, mergeConfig, custom) {
14536
14563
  addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig);
14537
14564
  if (leafer.isApp || custom) return;
14538
14565
  leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, e => {
14539
14566
  const move = leafer.getValidMove(e.moveX, e.moveY, false);
14567
+ if (getScrollType(leafer).includes("limit")) {
14568
+ const testMove = leafer.getValidMove(0, 0);
14569
+ if (testMove.x || testMove.y) {
14570
+ const maxX = 100, maxY = 200, resistance = e.moveType === "drag" ? .3 : .05;
14571
+ if (Math.abs(testMove.x) > maxX) move.x = 0; else move.x *= resistance;
14572
+ if (Math.abs(testMove.y) > maxY) move.y = 0; else move.y *= resistance;
14573
+ }
14574
+ }
14540
14575
  leafer.zoomLayer.move(move);
14541
14576
  }), leafer.on_(exports.MoveEvent.DRAG_ANIMATE, () => {
14542
- const move = leafer.getValidMove(0, 0);
14543
- if (move.x || move.y) leafer.interaction.stopDragAnimate();
14577
+ const testMove = leafer.getValidMove(0, 0);
14578
+ if (testMove.x || testMove.y) leafer.interaction.stopDragAnimate();
14544
14579
  }), leafer.on_(exports.MoveEvent.END, e => {
14545
14580
  LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY));
14546
14581
  }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, e => {
@@ -14825,15 +14860,15 @@ var LeaferUI = function(exports) {
14825
14860
  LeaferTypeCreator.run(type, this);
14826
14861
  };
14827
14862
  leafer.getValidMove = function(moveX, moveY, checkLimit = true) {
14828
- const {scroll: scroll, disabled: disabled} = this.app.config.move;
14863
+ const {disabled: disabled} = this.app.config.move;
14829
14864
  move.set(moveX, moveY);
14830
- if (scroll) {
14831
- const type = scroll === true ? "" : scroll;
14832
- if (type.includes("x")) move.y = 0; else if (type.includes("y")) move.x = 0; else Math.abs(move.x) > Math.abs(move.y) ? move.y = 0 : move.x = 0;
14833
- if (checkLimit && type.includes("limit")) {
14865
+ const scrollType = getScrollType(this);
14866
+ if (scrollType) {
14867
+ if (scrollType.includes("x")) move.y = 0; else if (scrollType.includes("y")) move.x = 0; else Math.abs(move.x) > Math.abs(move.y) ? move.y = 0 : move.x = 0;
14868
+ if (checkLimit && scrollType.includes("limit")) {
14834
14869
  bounds.set(this.__world).addPoint(this.zoomLayer);
14835
14870
  DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, "auto", move, true);
14836
- if (type.includes("x")) move.y = 0; else if (type.includes("y")) move.x = 0;
14871
+ if (scrollType.includes("x")) move.y = 0; else if (scrollType.includes("y")) move.x = 0;
14837
14872
  }
14838
14873
  }
14839
14874
  return {