@leafer/worker 1.12.2 → 1.12.4

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.
@@ -246,11 +246,13 @@ const Platform = {
246
246
  const ctx = canvas.getContext("2d");
247
247
  if (opacity) ctx.globalAlpha = opacity;
248
248
  ctx.imageSmoothingEnabled = smooth === false ? false : true;
249
- if (clip) {
250
- const scaleX = width / clip.width, scaleY = height / clip.height;
251
- ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
252
- ctx.drawImage(image, 0, 0, image.width, image.height);
253
- } else ctx.drawImage(image, 0, 0, width, height);
249
+ if (image) {
250
+ if (clip) {
251
+ const scaleX = width / clip.width, scaleY = height / clip.height;
252
+ ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
253
+ ctx.drawImage(image, 0, 0, image.width, image.height);
254
+ } else ctx.drawImage(image, 0, 0, width, height);
255
+ }
254
256
  return canvas;
255
257
  },
256
258
  setPatternTransform(pattern, transform, paint) {
@@ -4117,6 +4119,10 @@ class LeaferImage {
4117
4119
  get url() {
4118
4120
  return this.config.url;
4119
4121
  }
4122
+ get crossOrigin() {
4123
+ const {crossOrigin: crossOrigin} = this.config;
4124
+ return isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin;
4125
+ }
4120
4126
  get completed() {
4121
4127
  return this.ready || !!this.error;
4122
4128
  }
@@ -4134,12 +4140,14 @@ class LeaferImage {
4134
4140
  ImageManager.isFormat("svg", config) && (this.isSVG = true);
4135
4141
  ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
4136
4142
  }
4137
- load(onSuccess, onError) {
4143
+ load(onSuccess, onError, thumbSize) {
4138
4144
  if (!this.loading) {
4139
4145
  this.loading = true;
4140
- const {crossOrigin: crossOrigin} = this.config;
4141
4146
  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 => {
4147
+ return yield Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
4148
+ if (thumbSize) this.setThumbView(img);
4149
+ this.setView(img);
4150
+ }).catch(e => {
4143
4151
  this.error = e;
4144
4152
  this.onComplete(false);
4145
4153
  });
@@ -4160,9 +4168,11 @@ class LeaferImage {
4160
4168
  }
4161
4169
  setView(img) {
4162
4170
  this.ready = true;
4163
- this.width = img.naturalWidth || img.width;
4164
- this.height = img.naturalHeight || img.height;
4165
- this.view = img;
4171
+ if (!this.width) {
4172
+ this.width = img.width;
4173
+ this.height = img.height;
4174
+ this.view = img;
4175
+ }
4166
4176
  this.onComplete(true);
4167
4177
  }
4168
4178
  onComplete(isSuccess) {
@@ -4208,6 +4218,19 @@ class LeaferImage {
4208
4218
  Platform.image.setPatternTransform(pattern, transform, paint);
4209
4219
  return pattern;
4210
4220
  }
4221
+ getLoadUrl(_thumbSize) {
4222
+ return this.url;
4223
+ }
4224
+ setThumbView(_view) {}
4225
+ getThumbSize(_lod) {
4226
+ return undefined;
4227
+ }
4228
+ getMinLevel() {
4229
+ return undefined;
4230
+ }
4231
+ getLevelData(_level, _width, _height) {
4232
+ return undefined;
4233
+ }
4211
4234
  clearLevels(_checkUse) {}
4212
4235
  destroy() {
4213
4236
  this.clearLevels();
@@ -6937,7 +6960,7 @@ class LeafLevelList {
6937
6960
  }
6938
6961
  }
6939
6962
 
6940
- const version = "1.12.2";
6963
+ const version = "1.12.4";
6941
6964
 
6942
6965
  class LeaferCanvas extends LeaferCanvasBase {
6943
6966
  get allowBackgroundColor() {
@@ -10160,6 +10183,10 @@ MoveEvent.DRAG_ANIMATE = "move.drag_animate";
10160
10183
 
10161
10184
  MoveEvent.END = "move.end";
10162
10185
 
10186
+ MoveEvent.PULL_DOWN = "move.pull_down";
10187
+
10188
+ MoveEvent.REACH_BOTTOM = "move.reach_bottom";
10189
+
10163
10190
  MoveEvent = __decorate([ registerUIEvent() ], MoveEvent);
10164
10191
 
10165
10192
  let TouchEvent = class TouchEvent extends UIEvent {};
@@ -11629,7 +11656,7 @@ function image(ui, attrName, paint, boxBounds, firstUse) {
11629
11656
  ignoreRender(ui, false);
11630
11657
  onLoadError(ui, event, error);
11631
11658
  leafPaint.loadId = undefined;
11632
- });
11659
+ }, paint.lod && image.getThumbSize(paint.lod));
11633
11660
  if (ui.placeholderColor) {
11634
11661
  if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
11635
11662
  if (!image.ready) {
@@ -15884,15 +15911,28 @@ TextEditor = __decorate([ registerInnerEditor() ], TextEditor);
15884
15911
 
15885
15912
  Plugin.add("text-editor", "editor");
15886
15913
 
15914
+ function getScrollType(leafer) {
15915
+ const {scroll: scroll, disabled: disabled} = leafer.app.config.move;
15916
+ return !scroll || disabled ? "" : scroll === true ? "free" : scroll;
15917
+ }
15918
+
15887
15919
  function addViewport(leafer, mergeConfig, custom) {
15888
15920
  addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig);
15889
15921
  if (leafer.isApp || custom) return;
15890
15922
  leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, e => {
15891
15923
  const move = leafer.getValidMove(e.moveX, e.moveY, false);
15924
+ if (getScrollType(leafer).includes("limit")) {
15925
+ const testMove = leafer.getValidMove(0, 0);
15926
+ if (testMove.x || testMove.y) {
15927
+ const maxX = 100, maxY = 200, resistance = e.moveType === "drag" ? .3 : .05;
15928
+ if (Math.abs(testMove.x) > maxX) move.x = 0; else move.x *= resistance;
15929
+ if (Math.abs(testMove.y) > maxY) move.y = 0; else move.y *= resistance;
15930
+ }
15931
+ }
15892
15932
  leafer.zoomLayer.move(move);
15893
15933
  }), leafer.on_(MoveEvent.DRAG_ANIMATE, () => {
15894
- const move = leafer.getValidMove(0, 0);
15895
- if (move.x || move.y) leafer.interaction.stopDragAnimate();
15934
+ const testMove = leafer.getValidMove(0, 0);
15935
+ if (testMove.x || testMove.y) leafer.interaction.stopDragAnimate();
15896
15936
  }), leafer.on_(MoveEvent.END, e => {
15897
15937
  LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY));
15898
15938
  }), leafer.on_(ZoomEvent.BEFORE_ZOOM, e => {
@@ -16198,15 +16238,15 @@ leafer.initType = function(type) {
16198
16238
  };
16199
16239
 
16200
16240
  leafer.getValidMove = function(moveX, moveY, checkLimit = true) {
16201
- const {scroll: scroll, disabled: disabled} = this.app.config.move;
16241
+ const {disabled: disabled} = this.app.config.move;
16202
16242
  move$4.set(moveX, moveY);
16203
- if (scroll) {
16204
- const type = scroll === true ? "" : scroll;
16205
- 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;
16206
- if (checkLimit && type.includes("limit")) {
16243
+ const scrollType = getScrollType(this);
16244
+ if (scrollType) {
16245
+ 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;
16246
+ if (checkLimit && scrollType.includes("limit")) {
16207
16247
  bounds.set(this.__world).addPoint(this.zoomLayer);
16208
16248
  DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, "auto", move$4, true);
16209
- if (type.includes("x")) move$4.y = 0; else if (type.includes("y")) move$4.x = 0;
16249
+ if (scrollType.includes("x")) move$4.y = 0; else if (scrollType.includes("y")) move$4.x = 0;
16210
16250
  }
16211
16251
  }
16212
16252
  return {
@@ -18289,8 +18329,8 @@ let AnimateList = class AnimateList extends Animate {
18289
18329
  this.each(item => item.stop());
18290
18330
  this.emitType(AnimateEvent.STOP);
18291
18331
  }
18292
- seek(time) {
18293
- this.each(item => item.seek(time));
18332
+ seek(time, includeDelay) {
18333
+ this.each(item => item.seek(time, includeDelay));
18294
18334
  this.emitType(AnimateEvent.SEEK);
18295
18335
  }
18296
18336
  kill(complete, killStyle) {