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