zimjs 18.1.0 → 18.1.2
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/package.json +1 -1
- package/src/zim.js +53 -19
- package/ts-src/typings/zim/index.d.ts +1 -0
package/package.json
CHANGED
package/src/zim.js
CHANGED
|
@@ -770,7 +770,7 @@ RETURNS the modified Array
|
|
|
770
770
|
if (zot(array)) return;
|
|
771
771
|
if (!Array.isArray(array)) array = Object.values(arguments);
|
|
772
772
|
var i = array.length, j, temp;
|
|
773
|
-
if (i
|
|
773
|
+
if (i <= 1) return array;
|
|
774
774
|
if (different) {
|
|
775
775
|
var sur = {};
|
|
776
776
|
var arr = [];
|
|
@@ -2094,7 +2094,7 @@ pauseTimeLeft - if paused, get how much time is left once unpaused
|
|
|
2094
2094
|
if (zot(immediate)) immediate = false;
|
|
2095
2095
|
if (!zot(total) && (isNaN(total) || total<=0)) return;
|
|
2096
2096
|
if (zot(total)) total = -1;
|
|
2097
|
-
var obj = {count:0, total:total, paused:false, time:time, active:true, timeUnit:timeUnit};
|
|
2097
|
+
var obj = {count:(immediate && time <= (timeType=="s"?5/1000:5)) ? -1:0, total:total, paused:false, time:time, active:true, timeUnit:timeUnit};
|
|
2098
2098
|
|
|
2099
2099
|
if (pauseOnBlur) {
|
|
2100
2100
|
if (zot(zim.blurCheck)) zim.setBlurDetect();
|
|
@@ -2113,7 +2113,7 @@ pauseTimeLeft - if paused, get how much time is left once unpaused
|
|
|
2113
2113
|
checkTotal();
|
|
2114
2114
|
}, obj.interval*(timeType=="s"?1000:1));
|
|
2115
2115
|
}
|
|
2116
|
-
if (immediate) {
|
|
2116
|
+
if (immediate && time > (timeType=="s"?5/1000:5)) {
|
|
2117
2117
|
setTimeout(function() {
|
|
2118
2118
|
(call)(obj);
|
|
2119
2119
|
checkTotal();
|
|
@@ -24158,7 +24158,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
24158
24158
|
if (zot(rtl)) rtl = DS.rtl != null ? DS.rtl : false;
|
|
24159
24159
|
if (zot(lineAlign)) lineAlign = DS.lineAlign != null ? DS.lineAlign : rtl?"right":"left";
|
|
24160
24160
|
if (zot(lineValign)) lineValign = DS.lineValign != null ? DS.lineValign : "bottom";
|
|
24161
|
-
if (zot(lineWidth)) lineWidth = DS.lineWidth != null ? DS.lineWidth :
|
|
24161
|
+
if (zot(lineWidth)) lineWidth = DS.lineWidth != null ? DS.lineWidth : null;
|
|
24162
24162
|
if (zot(lineAlignLast)) lineAlignLast = DS.lineAlignLast != null ? DS.lineAlignLast : rtl?"right":"left";
|
|
24163
24163
|
if (zot(cache)) cache = DS.cache != null ? DS.cache : false;
|
|
24164
24164
|
|
|
@@ -25033,16 +25033,22 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
25033
25033
|
|
|
25034
25034
|
var originalLabel = !zot(label) && label.type == "Label";
|
|
25035
25035
|
if (zot(label)) label = DS.label != null ? DS.label : new zim.Label("Will this wind be so mighty as to lay low the mountains of the Earth?");
|
|
25036
|
-
|
|
25036
|
+
if (zot(size)) size = DS.size != null ? DS.size : originalLabel? label.size : 36;
|
|
25037
|
+
if (zot(spacingH)) spacingH = DS.spacingH != null ? DS.spacingH : size/2;
|
|
25038
|
+
if (zot(spacingV)) spacingV = DS.spacingV != null ? DS.spacingV : size/2;
|
|
25039
|
+
if (originalLabel) {
|
|
25040
|
+
var numWords = label.text.split(" ").length;
|
|
25041
|
+
var paddingT = label.background?label.paddingH*numWords*2:0;
|
|
25042
|
+
}
|
|
25043
|
+
if (zot(width)) width = DS.width != null ? DS.width : originalLabel ? label.width*(paddingT?1.05:1.07)+paddingT : 500;
|
|
25037
25044
|
if (zot(itemRegX)) itemRegX = DS.itemRegX != null ? DS.itemRegX : "center";
|
|
25038
25045
|
if (zot(itemRegY)) itemRegY = DS.itemRegY != null ? DS.itemRegY : "center";
|
|
25039
|
-
|
|
25046
|
+
|
|
25040
25047
|
if (zot(font)) font = DS.font != null ? DS.font : originalLabel? label.font : "arial";
|
|
25041
25048
|
if (zot(color)) color = DS.color != null ? DS.color : originalLabel? label.color : "black";
|
|
25042
25049
|
if (zot(backgroundColor)) backgroundColor = DS.backgroundColor != null ? DS.backgroundColor : originalLabel? label.backgroundColor : null;
|
|
25043
25050
|
if (zot(itemCache)) itemCache = DS.itemCache != null ? DS.itemCache : false;
|
|
25044
|
-
|
|
25045
|
-
if (zot(spacingV)) spacingV = DS.spacingV != null ? DS.spacingV : size/2;
|
|
25051
|
+
|
|
25046
25052
|
|
|
25047
25053
|
var that = this;
|
|
25048
25054
|
|
|
@@ -48552,6 +48558,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
48552
48558
|
|
|
48553
48559
|
content.cache(x, y, width, height);
|
|
48554
48560
|
|
|
48561
|
+
|
|
48555
48562
|
if (data) {
|
|
48556
48563
|
var image = content.cacheCanvas.toDataURL('image/' + type, quality);
|
|
48557
48564
|
if (cached) {
|
|
@@ -57403,7 +57410,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
57403
57410
|
var val;
|
|
57404
57411
|
tar.zimObj = {};
|
|
57405
57412
|
for (prop in obj) {
|
|
57406
|
-
if (extraTypes.indexOf(prop) >= 0) val = obj[prop];
|
|
57413
|
+
if (extraTypes.indexOf(prop) >= 0) val = obj[prop];
|
|
57407
57414
|
else val = zim.Pick.choose(obj[prop]);
|
|
57408
57415
|
tar.zimObj[prop] = tar[prop];
|
|
57409
57416
|
|
|
@@ -79944,6 +79951,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
79944
79951
|
tile.drag({boundary:tile, singleTouch:true});
|
|
79945
79952
|
}, timeType=="s"?(wait+time)*1000:wait+time);
|
|
79946
79953
|
}
|
|
79954
|
+
return that;
|
|
79947
79955
|
};
|
|
79948
79956
|
|
|
79949
79957
|
this._enabled = true;
|
|
@@ -87874,7 +87882,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
87874
87882
|
var duo; if (duo = zob(that.loadAssets, arguments, sig)) return duo;
|
|
87875
87883
|
}
|
|
87876
87884
|
|
|
87877
|
-
if (!zot(path)) {
|
|
87885
|
+
if (!zot(path)) {s
|
|
87878
87886
|
path = path.replace(/\/$/,"");
|
|
87879
87887
|
path = path + "/";
|
|
87880
87888
|
WW.PATH = path;
|
|
@@ -88374,9 +88382,9 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
88374
88382
|
|
|
88375
88383
|
if (WW.PATH!=null) zim.PATH = WW.PATH;
|
|
88376
88384
|
if (zim.PATH!=null) {
|
|
88377
|
-
zim.PATH.replace(/\/$/,"");
|
|
88385
|
+
zim.PATH = zim.PATH.replace(/\/$/,"");
|
|
88378
88386
|
zim.PATH = zim.PATH + "/";
|
|
88379
|
-
}
|
|
88387
|
+
}
|
|
88380
88388
|
if (second) {
|
|
88381
88389
|
var empty;
|
|
88382
88390
|
if (that.loadFailObj == "circles") empty = that.makeCircles(14);
|
|
@@ -89477,6 +89485,11 @@ keyOut(color, tolerance, replacement) - remove a certain color in the picture an
|
|
|
89477
89485
|
the default tolerance is .1 - the higher the tolerance the less sensitive the keying process - so more colors will be removed similar to the provided color
|
|
89478
89486
|
color and tolerance can be an array of colors and tolerances (or just one tolerance if all are the same)
|
|
89479
89487
|
replacement (default clear) a color to replace the keyed out color with or an optional array to match the colors array if an array is used
|
|
89488
|
+
destroy() - remove image references and dispose
|
|
89489
|
+
normal dispose() on a Pic() will just dispose the specific container and cloned bitmap
|
|
89490
|
+
leaving the original HTML image reference and ZIM Bitmap so that more Pic objects can be made from the loaded image
|
|
89491
|
+
destroy() will dispose the original ZIM Bitmap and set references to the HTML image to null letting HTML clear the image from memory
|
|
89492
|
+
|
|
89480
89493
|
Note: there is an outlineImage(pic, reverse) function that can be called to outline a DisplayObject - search docs for outlineImage
|
|
89481
89494
|
|
|
89482
89495
|
ZIM 4TH adds all the methods listed under Container (see above), such as:
|
|
@@ -89539,7 +89552,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
89539
89552
|
if (inner.type == "Bitmap" || inner.type == "Image") {
|
|
89540
89553
|
if (inner.type == "Bitmap") that.bitmap = inner.clone().addTo(that);
|
|
89541
89554
|
else that.bitmap = inner.getChildAt(0).clone().addTo(that);
|
|
89542
|
-
that.id =
|
|
89555
|
+
that.id = that.bitmap.id = file;
|
|
89556
|
+
zogb(that.id)
|
|
89543
89557
|
that.image = that.bitmap.image;
|
|
89544
89558
|
that.src = that.bitmap.src;
|
|
89545
89559
|
that.item = that.bitmap.item;
|
|
@@ -89552,7 +89566,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
89552
89566
|
} else {
|
|
89553
89567
|
inner.on("complete", function () {
|
|
89554
89568
|
that.bitmap = inner.getChildAt(0).clone().addTo(that);
|
|
89555
|
-
that.id =
|
|
89569
|
+
that.id = that.bitmap.id = file;
|
|
89556
89570
|
that.setBounds(null); // resets size
|
|
89557
89571
|
that.type = "Pic";
|
|
89558
89572
|
if (that.commands) {
|
|
@@ -89570,6 +89584,26 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
89570
89584
|
if (that.stage) that.stage.update();
|
|
89571
89585
|
});
|
|
89572
89586
|
}
|
|
89587
|
+
|
|
89588
|
+
this.destroy = function() {
|
|
89589
|
+
if (this.id && this.bitmap) {
|
|
89590
|
+
this.image = this.bitmap.image = null;
|
|
89591
|
+
var frame;
|
|
89592
|
+
if (this.stage && this.stage.frame) frame = this.stage.frame;
|
|
89593
|
+
else frame = WW.zdf;
|
|
89594
|
+
if (frame && frame.assets) {
|
|
89595
|
+
if (frame.assets[this.id]) {
|
|
89596
|
+
if (frame.assets[this.id].dispose) frame.assets[this.id].dispose();
|
|
89597
|
+
delete frame.assets[this.id];
|
|
89598
|
+
}
|
|
89599
|
+
}
|
|
89600
|
+
if (zim.assets[this.id]) {
|
|
89601
|
+
if (zim.assets[this.id].dispose) zim.assets[this.id].dispose();
|
|
89602
|
+
delete zim.assets[this.id];
|
|
89603
|
+
}
|
|
89604
|
+
}
|
|
89605
|
+
this.dispose();
|
|
89606
|
+
}
|
|
89573
89607
|
|
|
89574
89608
|
that.keyOut = function(color, tolerance, replacement) {
|
|
89575
89609
|
if (that.type=="AC"&&WW.zdf) {WW.zdf.ac("keyOut", arguments, that); return that;}
|
|
@@ -90205,7 +90239,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
90205
90239
|
|
|
90206
90240
|
if (WW.PATH!=null) zim.PATH = WW.PATH;
|
|
90207
90241
|
if (zim.PATH!=null) {
|
|
90208
|
-
zim.PATH.replace(/\/$/,"");
|
|
90242
|
+
zim.PATH = zim.PATH.replace(/\/$/,"");
|
|
90209
90243
|
zim.PATH = zim.PATH + "/";
|
|
90210
90244
|
}
|
|
90211
90245
|
|
|
@@ -90445,8 +90479,8 @@ zim.Dat = function(file) {
|
|
|
90445
90479
|
} else {
|
|
90446
90480
|
if (WW.PATH!=null) zim.PATH = WW.PATH;
|
|
90447
90481
|
if (zim.PATH!=null) {
|
|
90448
|
-
zim.
|
|
90449
|
-
zim.
|
|
90482
|
+
zim.PATH = zim.PATH.replace(/\/$/,"");
|
|
90483
|
+
zim.PATH = zim.PATH + "/";
|
|
90450
90484
|
}
|
|
90451
90485
|
var loader = zdf.loadAssets(file, zim.PATH);
|
|
90452
90486
|
loader.on("complete", function() {
|
|
@@ -94018,8 +94052,8 @@ animator - the Gifler animator
|
|
|
94018
94052
|
var f;
|
|
94019
94053
|
if (WW.PATH!=null) zim.PATH = WW.PATH;
|
|
94020
94054
|
if (zim.PATH!=null) {
|
|
94021
|
-
zim.
|
|
94022
|
-
zim.
|
|
94055
|
+
zim.PATH = zim.PATH.replace(/\/$/,"");
|
|
94056
|
+
zim.PATH = zim.PATH + "/";
|
|
94023
94057
|
}
|
|
94024
94058
|
if (file.match(/http/) || file.match(/^\//)) f = file;
|
|
94025
94059
|
else f = (zim.PATH?zim.PATH:"")+file;
|
|
@@ -3920,6 +3920,7 @@ declare namespace zim {
|
|
|
3920
3920
|
constructor(config_or_file?: string, width?: number, height?: number, noCors?: boolean, style?: boolean, group?: string, inherit?: {})
|
|
3921
3921
|
constructor(config: { file?: string, width?: number, height?: number, noCors?: boolean, style?: boolean, group?: string, inherit?: {} })
|
|
3922
3922
|
keyOut(color?: string, tolerance?: number, replacement?: color): this
|
|
3923
|
+
destroy(): void
|
|
3923
3924
|
readonly file: string
|
|
3924
3925
|
readonly src: string
|
|
3925
3926
|
readonly image: HTMLImageElement
|