@leafer-game/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.
package/dist/worker.js CHANGED
@@ -228,11 +228,13 @@ var LeaferUI = function(exports) {
228
228
  const ctx = canvas.getContext("2d");
229
229
  if (opacity) ctx.globalAlpha = opacity;
230
230
  ctx.imageSmoothingEnabled = smooth === false ? false : true;
231
- if (clip) {
232
- const scaleX = width / clip.width, scaleY = height / clip.height;
233
- ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
234
- ctx.drawImage(image, 0, 0, image.width, image.height);
235
- } else ctx.drawImage(image, 0, 0, width, height);
231
+ if (image) {
232
+ if (clip) {
233
+ const scaleX = width / clip.width, scaleY = height / clip.height;
234
+ ctx.setTransform(scaleX, 0, 0, scaleY, -clip.x * scaleX, -clip.y * scaleY);
235
+ ctx.drawImage(image, 0, 0, image.width, image.height);
236
+ } else ctx.drawImage(image, 0, 0, width, height);
237
+ }
236
238
  return canvas;
237
239
  },
238
240
  setPatternTransform(pattern, transform, paint) {
@@ -3875,6 +3877,10 @@ var LeaferUI = function(exports) {
3875
3877
  get url() {
3876
3878
  return this.config.url;
3877
3879
  }
3880
+ get crossOrigin() {
3881
+ const {crossOrigin: crossOrigin} = this.config;
3882
+ return isUndefined(crossOrigin) ? Platform.image.crossOrigin : crossOrigin;
3883
+ }
3878
3884
  get completed() {
3879
3885
  return this.ready || !!this.error;
3880
3886
  }
@@ -3892,12 +3898,14 @@ var LeaferUI = function(exports) {
3892
3898
  ImageManager.isFormat("svg", config) && (this.isSVG = true);
3893
3899
  ImageManager.hasAlphaPixel(config) && (this.hasAlphaPixel = true);
3894
3900
  }
3895
- load(onSuccess, onError) {
3901
+ load(onSuccess, onError, thumbSize) {
3896
3902
  if (!this.loading) {
3897
3903
  this.loading = true;
3898
- const {crossOrigin: crossOrigin} = this.config;
3899
3904
  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 => {
3905
+ return yield Platform.origin.loadImage(this.getLoadUrl(thumbSize), this.crossOrigin, this).then(img => {
3906
+ if (thumbSize) this.setThumbView(img);
3907
+ this.setView(img);
3908
+ }).catch(e => {
3901
3909
  this.error = e;
3902
3910
  this.onComplete(false);
3903
3911
  });
@@ -3918,9 +3926,11 @@ var LeaferUI = function(exports) {
3918
3926
  }
3919
3927
  setView(img) {
3920
3928
  this.ready = true;
3921
- this.width = img.naturalWidth || img.width;
3922
- this.height = img.naturalHeight || img.height;
3923
- this.view = img;
3929
+ if (!this.width) {
3930
+ this.width = img.width;
3931
+ this.height = img.height;
3932
+ this.view = img;
3933
+ }
3924
3934
  this.onComplete(true);
3925
3935
  }
3926
3936
  onComplete(isSuccess) {
@@ -3966,6 +3976,19 @@ var LeaferUI = function(exports) {
3966
3976
  Platform.image.setPatternTransform(pattern, transform, paint);
3967
3977
  return pattern;
3968
3978
  }
3979
+ getLoadUrl(_thumbSize) {
3980
+ return this.url;
3981
+ }
3982
+ setThumbView(_view) {}
3983
+ getThumbSize(_lod) {
3984
+ return undefined;
3985
+ }
3986
+ getMinLevel() {
3987
+ return undefined;
3988
+ }
3989
+ getLevelData(_level, _width, _height) {
3990
+ return undefined;
3991
+ }
3969
3992
  clearLevels(_checkUse) {}
3970
3993
  destroy() {
3971
3994
  this.clearLevels();
@@ -6526,7 +6549,7 @@ var LeaferUI = function(exports) {
6526
6549
  this.levelMap = null;
6527
6550
  }
6528
6551
  }
6529
- const version = "1.12.2";
6552
+ const version = "1.12.4";
6530
6553
  class LeaferCanvas extends LeaferCanvasBase {
6531
6554
  get allowBackgroundColor() {
6532
6555
  return true;
@@ -9416,6 +9439,8 @@ var LeaferUI = function(exports) {
9416
9439
  exports.MoveEvent.MOVE = "move";
9417
9440
  exports.MoveEvent.DRAG_ANIMATE = "move.drag_animate";
9418
9441
  exports.MoveEvent.END = "move.end";
9442
+ exports.MoveEvent.PULL_DOWN = "move.pull_down";
9443
+ exports.MoveEvent.REACH_BOTTOM = "move.reach_bottom";
9419
9444
  exports.MoveEvent = __decorate([ registerUIEvent() ], exports.MoveEvent);
9420
9445
  exports.TouchEvent = class TouchEvent extends UIEvent {};
9421
9446
  exports.TouchEvent = __decorate([ registerUIEvent() ], exports.TouchEvent);
@@ -10790,7 +10815,7 @@ var LeaferUI = function(exports) {
10790
10815
  ignoreRender(ui, false);
10791
10816
  onLoadError(ui, event, error);
10792
10817
  leafPaint.loadId = undefined;
10793
- });
10818
+ }, paint.lod && image.getThumbSize(paint.lod));
10794
10819
  if (ui.placeholderColor) {
10795
10820
  if (!ui.placeholderDelay) image.isPlacehold = true; else setTimeout(() => {
10796
10821
  if (!image.ready) {
@@ -12931,8 +12956,8 @@ var LeaferUI = function(exports) {
12931
12956
  this.each(item => item.stop());
12932
12957
  this.emitType(AnimateEvent.STOP);
12933
12958
  }
12934
- seek(time) {
12935
- this.each(item => item.seek(time));
12959
+ seek(time, includeDelay) {
12960
+ this.each(item => item.seek(time, includeDelay));
12936
12961
  this.emitType(AnimateEvent.SEEK);
12937
12962
  }
12938
12963
  kill(complete, killStyle) {