@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.
@@ -4117,6 +4117,10 @@ class LeaferImage {
4117
4117
  get url() {
4118
4118
  return this.config.url;
4119
4119
  }
4120
+ get crossOrigin() {
4121
+ const {crossOrigin: crossOrigin} = this.config;
4122
+ return isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin;
4123
+ }
4120
4124
  get completed() {
4121
4125
  return this.ready || !!this.error;
4122
4126
  }
@@ -4134,12 +4138,14 @@ class LeaferImage {
4134
4138
  ImageManager.isFormat("svg", config) && (this.isSVG = true);
4135
4139
  ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
4136
4140
  }
4137
- load(onSuccess, onError) {
4141
+ load(onSuccess, onError, thumbSize) {
4138
4142
  if (!this.loading) {
4139
4143
  this.loading = true;
4140
- const {crossOrigin: crossOrigin} = this.config;
4141
4144
  Resource.tasker.add(() => __awaiter(this, void 0, void 0, function*() {
4142
- return yield Platform.origin.loadImage(this.url, isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin, this).then(img => this.setView(img)).catch(e => {
4145
+ return yield Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
4146
+ if (thumbSize) this.setThumbView(img);
4147
+ this.setView(img);
4148
+ }).catch(e => {
4143
4149
  this.error = e;
4144
4150
  this.onComplete(false);
4145
4151
  });
@@ -4160,9 +4166,11 @@ class LeaferImage {
4160
4166
  }
4161
4167
  setView(img) {
4162
4168
  this.ready = true;
4163
- this.width = img.naturalWidth || img.width;
4164
- this.height = img.naturalHeight || img.height;
4165
- this.view = img;
4169
+ if (!this.width) {
4170
+ this.width = img.width;
4171
+ this.height = img.height;
4172
+ this.view = img;
4173
+ }
4166
4174
  this.onComplete(true);
4167
4175
  }
4168
4176
  onComplete(isSuccess) {
@@ -4208,6 +4216,19 @@ class LeaferImage {
4208
4216
  Platform.image.setPatternTransform(pattern, transform, paint);
4209
4217
  return pattern;
4210
4218
  }
4219
+ getLoadUrl(_thumbSize) {
4220
+ return this.url;
4221
+ }
4222
+ setThumbView(_view) {}
4223
+ getThumbSize() {
4224
+ return undefined;
4225
+ }
4226
+ getMinLevel() {
4227
+ return undefined;
4228
+ }
4229
+ getLevelData(_level) {
4230
+ return undefined;
4231
+ }
4211
4232
  clearLevels(_checkUse) {}
4212
4233
  destroy() {
4213
4234
  this.clearLevels();
@@ -6937,7 +6958,7 @@ class LeafLevelList {
6937
6958
  }
6938
6959
  }
6939
6960
 
6940
- const version = "1.12.2";
6961
+ const version = "1.12.3";
6941
6962
 
6942
6963
  class LeaferCanvas extends LeaferCanvasBase {
6943
6964
  get allowBackgroundColor() {
@@ -10160,6 +10181,10 @@ MoveEvent.DRAG_ANIMATE = "move.drag_animate";
10160
10181
 
10161
10182
  MoveEvent.END = "move.end";
10162
10183
 
10184
+ MoveEvent.PULL_DOWN = "move.pull_down";
10185
+
10186
+ MoveEvent.REACH_BOTTOM = "move.reach_bottom";
10187
+
10163
10188
  MoveEvent = __decorate([ registerUIEvent() ], MoveEvent);
10164
10189
 
10165
10190
  let TouchEvent = class TouchEvent extends UIEvent {};
@@ -11629,7 +11654,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11629
11654
  ignoreRender(ui, false);
11630
11655
  onLoadError(ui, event, error);
11631
11656
  leafPaint.loadId = undefined;
11632
- });
11657
+ }, paint.lod && image.getThumbSize());
11633
11658
  if (ui.placeholderColor) {
11634
11659
  if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
11635
11660
  if (!image.ready) {
@@ -15630,15 +15655,28 @@ UI.setEditInner = function(editorName) {
15630
15655
  this.changeAttr("editInner", editorName);
15631
15656
  };
15632
15657
 
15658
+ function getScrollType(leafer) {
15659
+ const {scroll: scroll, disabled: disabled} = leafer.app.config.move;
15660
+ return !scroll || disabled ? "" : scroll === true ? "free" : scroll;
15661
+ }
15662
+
15633
15663
  function addViewport(leafer, mergeConfig, custom) {
15634
15664
  addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig);
15635
15665
  if (leafer.isApp || custom) return;
15636
15666
  leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, e => {
15637
15667
  const move = leafer.getValidMove(e.moveX, e.moveY, false);
15668
+ if (getScrollType(leafer).includes("limit")) {
15669
+ const testMove = leafer.getValidMove(0, 0);
15670
+ if (testMove.x || testMove.y) {
15671
+ const maxX = 100, maxY = 200, resistance = e.moveType === "drag" ? .3 : .05;
15672
+ if (Math.abs(testMove.x) > maxX) move.x = 0; else move.x *= resistance;
15673
+ if (Math.abs(testMove.y) > maxY) move.y = 0; else move.y *= resistance;
15674
+ }
15675
+ }
15638
15676
  leafer.zoomLayer.move(move);
15639
15677
  }), leafer.on_(MoveEvent.DRAG_ANIMATE, () => {
15640
- const move = leafer.getValidMove(0, 0);
15641
- if (move.x || move.y) leafer.interaction.stopDragAnimate();
15678
+ const testMove = leafer.getValidMove(0, 0);
15679
+ if (testMove.x || testMove.y) leafer.interaction.stopDragAnimate();
15642
15680
  }), leafer.on_(MoveEvent.END, e => {
15643
15681
  LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY));
15644
15682
  }), leafer.on_(ZoomEvent.BEFORE_ZOOM, e => {
@@ -15944,15 +15982,15 @@ leafer.initType = function(type) {
15944
15982
  };
15945
15983
 
15946
15984
  leafer.getValidMove = function(moveX, moveY, checkLimit = true) {
15947
- const {scroll: scroll, disabled: disabled} = this.app.config.move;
15985
+ const {disabled: disabled} = this.app.config.move;
15948
15986
  move.set(moveX, moveY);
15949
- if (scroll) {
15950
- const type = scroll === true ? "" : scroll;
15951
- 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;
15952
- if (checkLimit && type.includes("limit")) {
15987
+ const scrollType = getScrollType(this);
15988
+ if (scrollType) {
15989
+ 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;
15990
+ if (checkLimit && scrollType.includes("limit")) {
15953
15991
  bounds.set(this.__world).addPoint(this.zoomLayer);
15954
15992
  DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, "auto", move, true);
15955
- if (type.includes("x")) move.y = 0; else if (type.includes("y")) move.x = 0;
15993
+ if (scrollType.includes("x")) move.y = 0; else if (scrollType.includes("y")) move.x = 0;
15956
15994
  }
15957
15995
  }
15958
15996
  return {