@leafer-editor/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 +58 -21
- package/dist/worker.min.js +1 -1
- package/dist/worker.min.js.map +1 -1
- package/dist/worker.module.js +61 -21
- package/dist/worker.module.min.js +1 -1
- package/dist/worker.module.min.js.map +1 -1
- package/package.json +17 -17
package/dist/worker.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() {
|
|
@@ -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) {
|
|
@@ -15630,15 +15657,28 @@ UI.setEditInner = function(editorName) {
|
|
|
15630
15657
|
this.changeAttr("editInner", editorName);
|
|
15631
15658
|
};
|
|
15632
15659
|
|
|
15660
|
+
function getScrollType(leafer) {
|
|
15661
|
+
const {scroll: scroll, disabled: disabled} = leafer.app.config.move;
|
|
15662
|
+
return !scroll || disabled ? "" : scroll === true ? "free" : scroll;
|
|
15663
|
+
}
|
|
15664
|
+
|
|
15633
15665
|
function addViewport(leafer, mergeConfig, custom) {
|
|
15634
15666
|
addViewportConfig(leafer.parentApp ? leafer.parentApp : leafer, mergeConfig);
|
|
15635
15667
|
if (leafer.isApp || custom) return;
|
|
15636
15668
|
leafer.__eventIds.push(leafer.on_(MoveEvent.BEFORE_MOVE, e => {
|
|
15637
15669
|
const move = leafer.getValidMove(e.moveX, e.moveY, false);
|
|
15670
|
+
if (getScrollType(leafer).includes("limit")) {
|
|
15671
|
+
const testMove = leafer.getValidMove(0, 0);
|
|
15672
|
+
if (testMove.x || testMove.y) {
|
|
15673
|
+
const maxX = 100, maxY = 200, resistance = e.moveType === "drag" ? .3 : .05;
|
|
15674
|
+
if (Math.abs(testMove.x) > maxX) move.x = 0; else move.x *= resistance;
|
|
15675
|
+
if (Math.abs(testMove.y) > maxY) move.y = 0; else move.y *= resistance;
|
|
15676
|
+
}
|
|
15677
|
+
}
|
|
15638
15678
|
leafer.zoomLayer.move(move);
|
|
15639
15679
|
}), leafer.on_(MoveEvent.DRAG_ANIMATE, () => {
|
|
15640
|
-
const
|
|
15641
|
-
if (
|
|
15680
|
+
const testMove = leafer.getValidMove(0, 0);
|
|
15681
|
+
if (testMove.x || testMove.y) leafer.interaction.stopDragAnimate();
|
|
15642
15682
|
}), leafer.on_(MoveEvent.END, e => {
|
|
15643
15683
|
LeafHelper.animateMove(leafer.zoomLayer, leafer.getValidMove(e.moveX, e.moveY));
|
|
15644
15684
|
}), leafer.on_(ZoomEvent.BEFORE_ZOOM, e => {
|
|
@@ -15944,15 +15984,15 @@ leafer.initType = function(type) {
|
|
|
15944
15984
|
};
|
|
15945
15985
|
|
|
15946
15986
|
leafer.getValidMove = function(moveX, moveY, checkLimit = true) {
|
|
15947
|
-
const {
|
|
15987
|
+
const {disabled: disabled} = this.app.config.move;
|
|
15948
15988
|
move.set(moveX, moveY);
|
|
15949
|
-
|
|
15950
|
-
|
|
15951
|
-
if (
|
|
15952
|
-
if (checkLimit &&
|
|
15989
|
+
const scrollType = getScrollType(this);
|
|
15990
|
+
if (scrollType) {
|
|
15991
|
+
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;
|
|
15992
|
+
if (checkLimit && scrollType.includes("limit")) {
|
|
15953
15993
|
bounds.set(this.__world).addPoint(this.zoomLayer);
|
|
15954
15994
|
DragBoundsHelper.getValidMove(bounds, this.canvas.bounds, "auto", move, true);
|
|
15955
|
-
if (
|
|
15995
|
+
if (scrollType.includes("x")) move.y = 0; else if (scrollType.includes("y")) move.x = 0;
|
|
15956
15996
|
}
|
|
15957
15997
|
}
|
|
15958
15998
|
return {
|