@leafer/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) {
@@ -14778,15 +14801,27 @@ var LeaferUI = function(exports) {
14778
14801
  };
14779
14802
  exports.TextEditor = __decorate([ registerInnerEditor() ], exports.TextEditor);
14780
14803
  Plugin.add("text-editor", "editor");
14804
+ function getScrollType(leafer) {
14805
+ const {scroll: scroll, disabled: disabled} = leafer.app.config.move;
14806
+ return !scroll || disabled ? "" : scroll === true ? "free" : scroll;
14807
+ }
14781
14808
  function addViewport(leafer, mergeConfig, custom) {
14782
14809
  addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig);
14783
14810
  if (leafer.isApp || custom) return;
14784
14811
  leafer.__eventIds.push(leafer.on_(exports.MoveEvent.BEFORE_MOVE, e => {
14785
14812
  const move = leafer.getValidMove(e.moveX, e.moveY, false);
14813
+ if (getScrollType(leafer).includes("limit")) {
14814
+ const testMove = leafer.getValidMove(0, 0);
14815
+ if (testMove.x || testMove.y) {
14816
+ const maxX = 100, maxY = 200, resistance = e.moveType === "drag" ? .3 : .05;
14817
+ if (Math.abs(testMove.x) > maxX) move.x = 0; else move.x *= resistance;
14818
+ if (Math.abs(testMove.y) > maxY) move.y = 0; else move.y *= resistance;
14819
+ }
14820
+ }
14786
14821
  leafer.zoomLayer.move(move);
14787
14822
  }), leafer.on_(exports.MoveEvent.DRAG_ANIMATE, () => {
14788
- const move = leafer.getValidMove(0, 0);
14789
- if (move.x || move.y) leafer.interaction.stopDragAnimate();
14823
+ const testMove = leafer.getValidMove(0, 0);
14824
+ if (testMove.x || testMove.y) leafer.interaction.stopDragAnimate();
14790
14825
  }), leafer.on_(exports.MoveEvent.END, e => {
14791
14826
  LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY));
14792
14827
  }), leafer.on_(exports.ZoomEvent.BEFORE_ZOOM, e => {
@@ -15071,15 +15106,15 @@ var LeaferUI = function(exports) {
15071
15106
  LeaferTypeCreator.run(type, this);
15072
15107
  };
15073
15108
  leafer.getValidMove = function(moveX, moveY, checkLimit = true) {
15074
- const {scroll: scroll, disabled: disabled} = this.app.config.move;
15109
+ const {disabled: disabled} = this.app.config.move;
15075
15110
  move$4.set(moveX, moveY);
15076
- if (scroll) {
15077
- const type = scroll === true ? "" : scroll;
15078
- if (type.includes("x")) move$4.y = 0; else if (type.includes("y")) move$4.x = 0; else Math.abs(move$4.x) > Math.abs(move$4.y) ? move$4.y = 0 : move$4.x = 0;
15079
- if (checkLimit && type.includes("limit")) {
15111
+ const scrollType = getScrollType(this);
15112
+ if (scrollType) {
15113
+ if (scrollType.includes("x")) move$4.y = 0; else if (scrollType.includes("y")) move$4.x = 0; else Math.abs(move$4.x) > Math.abs(move$4.y) ? move$4.y = 0 : move$4.x = 0;
15114
+ if (checkLimit && scrollType.includes("limit")) {
15080
15115
  bounds.set(this.__world).addPoint(this.zoomLayer);
15081
15116
  DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, "auto", move$4, true);
15082
- if (type.includes("x")) move$4.y = 0; else if (type.includes("y")) move$4.x = 0;
15117
+ if (scrollType.includes("x")) move$4.y = 0; else if (scrollType.includes("y")) move$4.x = 0;
15083
15118
  }
15084
15119
  }
15085
15120
  return {
@@ -16987,8 +17022,8 @@ var LeaferUI = function(exports) {
16987
17022
  this.each(item => item.stop());
16988
17023
  this.emitType(AnimateEvent.STOP);
16989
17024
  }
16990
- seek(time) {
16991
- this.each(item => item.seek(time));
17025
+ seek(time, includeDelay) {
17026
+ this.each(item => item.seek(time, includeDelay));
16992
17027
  this.emitType(AnimateEvent.SEEK);
16993
17028
  }
16994
17029
  kill(complete, killStyle) {