@leafer/miniapp 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() {
@@ -10313,6 +10334,10 @@ MoveEvent.DRAG_ANIMATE = "move.drag_animate";
10313
10334
 
10314
10335
  MoveEvent.END = "move.end";
10315
10336
 
10337
+ MoveEvent.PULL_DOWN = "move.pull_down";
10338
+
10339
+ MoveEvent.REACH_BOTTOM = "move.reach_bottom";
10340
+
10316
10341
  MoveEvent = __decorate([ registerUIEvent() ], MoveEvent);
10317
10342
 
10318
10343
  let TouchEvent = class TouchEvent extends UIEvent {};
@@ -11894,7 +11919,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11894
11919
  ignoreRender(ui, false);
11895
11920
  onLoadError(ui, event, error);
11896
11921
  leafPaint.loadId = undefined;
11897
- });
11922
+ }, paint.lod && image.getThumbSize());
11898
11923
  if (ui.placeholderColor) {
11899
11924
  if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
11900
11925
  if (!image.ready) {
@@ -15901,15 +15926,28 @@ UI.setEditInner = function(editorName) {
15901
15926
  this.changeAttr("editInner", editorName);
15902
15927
  };
15903
15928
 
15929
+ function getScrollType(leafer) {
15930
+ const {scroll: scroll, disabled: disabled} = leafer.app.config.move;
15931
+ return !scroll || disabled ? "" : scroll === true ? "free" : scroll;
15932
+ }
15933
+
15904
15934
  function addViewport(leafer, mergeConfig, custom) {
15905
15935
  addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig);
15906
15936
  if (leafer.isApp || custom) return;
15907
15937
  leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, e => {
15908
15938
  const move = leafer.getValidMove(e.moveX, e.moveY, false);
15939
+ if (getScrollType(leafer).includes("limit")) {
15940
+ const testMove = leafer.getValidMove(0, 0);
15941
+ if (testMove.x || testMove.y) {
15942
+ const maxX = 100, maxY = 200, resistance = e.moveType === "drag" ? .3 : .05;
15943
+ if (Math.abs(testMove.x) > maxX) move.x = 0; else move.x *= resistance;
15944
+ if (Math.abs(testMove.y) > maxY) move.y = 0; else move.y *= resistance;
15945
+ }
15946
+ }
15909
15947
  leafer.zoomLayer.move(move);
15910
15948
  }), leafer.on_(MoveEvent.DRAG_ANIMATE, () => {
15911
- const move = leafer.getValidMove(0, 0);
15912
- if (move.x || move.y) leafer.interaction.stopDragAnimate();
15949
+ const testMove = leafer.getValidMove(0, 0);
15950
+ if (testMove.x || testMove.y) leafer.interaction.stopDragAnimate();
15913
15951
  }), leafer.on_(MoveEvent.END, e => {
15914
15952
  LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY));
15915
15953
  }), leafer.on_(ZoomEvent.BEFORE_ZOOM, e => {
@@ -16215,15 +16253,15 @@ leafer.initType = function(type) {
16215
16253
  };
16216
16254
 
16217
16255
  leafer.getValidMove = function(moveX, moveY, checkLimit = true) {
16218
- const {scroll: scroll, disabled: disabled} = this.app.config.move;
16256
+ const {disabled: disabled} = this.app.config.move;
16219
16257
  move$4.set(moveX, moveY);
16220
- if (scroll) {
16221
- const type = scroll === true ? "" : scroll;
16222
- 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;
16223
- if (checkLimit && type.includes("limit")) {
16258
+ const scrollType = getScrollType(this);
16259
+ if (scrollType) {
16260
+ 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;
16261
+ if (checkLimit && scrollType.includes("limit")) {
16224
16262
  bounds.set(this.__world).addPoint(this.zoomLayer);
16225
16263
  DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, "auto", move$4, true);
16226
- if (type.includes("x")) move$4.y = 0; else if (type.includes("y")) move$4.x = 0;
16264
+ if (scrollType.includes("x")) move$4.y = 0; else if (scrollType.includes("y")) move$4.x = 0;
16227
16265
  }
16228
16266
  }
16229
16267
  return {
@@ -18167,8 +18205,8 @@ let AnimateList = class AnimateList extends Animate {
18167
18205
  this.each(item => item.stop());
18168
18206
  this.emitType(AnimateEvent.STOP);
18169
18207
  }
18170
- seek(time) {
18171
- this.each(item => item.seek(time));
18208
+ seek(time, includeDelay) {
18209
+ this.each(item => item.seek(time, includeDelay));
18172
18210
  this.emitType(AnimateEvent.SEEK);
18173
18211
  }
18174
18212
  kill(complete, killStyle) {