zimjs 16.4.4 → 16.4.6
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 +138 -24
package/package.json
CHANGED
package/src/zim.js
CHANGED
|
@@ -908,7 +908,7 @@ END EXAMPLE
|
|
|
908
908
|
|
|
909
909
|
EXAMPLE
|
|
910
910
|
// Remember the seed for a user with localStorage (like a cookie)
|
|
911
|
-
|
|
911
|
+
let seed = rand(100000000);
|
|
912
912
|
if (localStorage) {
|
|
913
913
|
if (localStorage.seed) seed = localStorage.seed;
|
|
914
914
|
else localStorage.seed = seed;
|
|
@@ -925,7 +925,7 @@ new Circle(100, [red, green, blue]).center().mov(0,300);
|
|
|
925
925
|
|
|
926
926
|
seedRandom(); // clears the seed
|
|
927
927
|
// below will be a random color each time
|
|
928
|
-
new Circle(100, [red, green, blue]).center().mov(
|
|
928
|
+
new Circle(100, [red, green, blue]).center().mov(200,300);
|
|
929
929
|
END EXAMPLE
|
|
930
930
|
|
|
931
931
|
PARAMETERS
|
|
@@ -9107,12 +9107,23 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
9107
9107
|
d+=that.borderWidth?that.borderWidth*2:0;
|
|
9108
9108
|
}
|
|
9109
9109
|
if (zot(margin)) margin = 0;
|
|
9110
|
-
|
|
9110
|
+
|
|
9111
|
+
that.cjsContainer_cache(a-margin,b-margin,c+margin*2,d+margin*2,scale,options,rtl,willReadFrequently);
|
|
9111
9112
|
|
|
9113
|
+
// if (bounds && options && options.adjustBounds && (a!=bounds.x || b!=bounds.y || c!=bounds.width || d!=bounds.height)) {
|
|
9114
|
+
// zog("015")
|
|
9115
|
+
// that.setBounds(a, b, c, d);
|
|
9116
|
+
// that.reg(a,b);
|
|
9117
|
+
// that.hitArea = new zim.Shape().f(black).dr(a-margin,b-margin,c+margin*2,d+margin*2);
|
|
9118
|
+
// }
|
|
9119
|
+
|
|
9112
9120
|
if (bounds && ((that.width == 0 && c > 0) || (options && options.adjustBounds))) {
|
|
9113
|
-
|
|
9114
|
-
|
|
9115
|
-
|
|
9121
|
+
var oW = that.width;
|
|
9122
|
+
that.setBounds(a, b, c, d);
|
|
9123
|
+
if (oW != 0) {
|
|
9124
|
+
if (a!=bounds.x || b!=bounds.y || c!=bounds.width || d!=bounds.height) that.reg(a,b);
|
|
9125
|
+
that.hitArea = new zim.Shape().f(black).dr(a-margin,b-margin,c+margin*2,d+margin*2);
|
|
9126
|
+
}
|
|
9116
9127
|
}
|
|
9117
9128
|
that.z_bc = that.canvas = that.cacheCanvas;
|
|
9118
9129
|
return that;
|
|
@@ -10020,12 +10031,14 @@ zim.Bitmap = function(image, width, height, left, top, scale, style, group, inhe
|
|
|
10020
10031
|
displayCheck = true;
|
|
10021
10032
|
var cached = image.cacheCanvas;
|
|
10022
10033
|
var original = image;
|
|
10034
|
+
var bOriginal = original.getBounds();
|
|
10023
10035
|
image.cache(left,top,width,height,scale); // do not chain on end as might be createjs image
|
|
10024
10036
|
this.z_bc = image = image.cacheCanvas; // what we will pass to bitmap
|
|
10025
10037
|
}
|
|
10026
10038
|
}
|
|
10027
10039
|
this.cjsBitmap_constructor(image);
|
|
10028
10040
|
if (original && !cached) original.uncache();
|
|
10041
|
+
if (bOriginal) original.setBounds(bOriginal.x, bOriginal.y, bOriginal.width, bOriginal.height);
|
|
10029
10042
|
|
|
10030
10043
|
var that = this;
|
|
10031
10044
|
this.type = "Bitmap";
|
|
@@ -29648,7 +29661,7 @@ corner - (default 0) the corner radius if there is a backdropColor provided
|
|
|
29648
29661
|
can also be an array of [topLeft, topRight, bottomRight, bottomLeft]
|
|
29649
29662
|
indicatorType - (default "dot" or "circle") can also be "box" or "square", "heart", "star"
|
|
29650
29663
|
or pass in a ZIM Emoji and Indicator will fade alpha to backgroundAlpha parameter setting for unselected emojis
|
|
29651
|
-
|
|
29664
|
+
or pass any display object and the this will be used
|
|
29652
29665
|
fill - (default false) set to true to fill in lights to the left of the selectedIndex
|
|
29653
29666
|
scale - (default 1) for all the lights including spacing
|
|
29654
29667
|
lightScale - (default 1) scale for each light - keeping the spacing unchanged
|
|
@@ -29656,8 +29669,8 @@ interactive - (default false) set to true to make lights clickable
|
|
|
29656
29669
|
clicking on first light when first light is only light on, will toggle light
|
|
29657
29670
|
shadowColor - (default rgba(0,0,0,.3)) set to -1 for no shadow
|
|
29658
29671
|
shadowBlur - (default 5) the shadow blur if shadow is set
|
|
29659
|
-
selectedIndex - (default 0) - set the selectedIndex at start
|
|
29660
|
-
backgroundAlpha - (default 1 or .2 if indicatorType is Emoji) - affects only Emoji indicatorType
|
|
29672
|
+
selectedIndex - (default 0) - set the selectedIndex at start. Use -1 for no indicator at start.
|
|
29673
|
+
backgroundAlpha - (default 1 or .2 if indicatorType is Emoji) - affects only Emoji and custom DisplayObject indicatorType
|
|
29661
29674
|
style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
|
|
29662
29675
|
group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
|
|
29663
29676
|
inherit - (default null) used internally but can receive an {} of styles directly
|
|
@@ -30870,6 +30883,91 @@ new List({
|
|
|
30870
30883
|
}).resize(300).center()
|
|
30871
30884
|
END EXAMPLE
|
|
30872
30885
|
|
|
30886
|
+
EXAMPLE
|
|
30887
|
+
const accordionData = {
|
|
30888
|
+
menu: {
|
|
30889
|
+
"Europe": ["London", "Paris", "Oslo"],
|
|
30890
|
+
"Canada": {
|
|
30891
|
+
"Ontario": {
|
|
30892
|
+
"Hamilton": {
|
|
30893
|
+
"Ancaster": [],
|
|
30894
|
+
"Dundas": [],
|
|
30895
|
+
"Westdale": []
|
|
30896
|
+
},
|
|
30897
|
+
"Toronto": [],
|
|
30898
|
+
"Ottawa": []
|
|
30899
|
+
},
|
|
30900
|
+
"British Columbia": ["Victoria", "Vancouver"],
|
|
30901
|
+
"Quebec": ["Montreal", "Quebec City"]
|
|
30902
|
+
},
|
|
30903
|
+
"United States": ["New York", "Atlanta", "San Francisco", "Portland"],
|
|
30904
|
+
"China": ["Bejing", "Hong Kong"],
|
|
30905
|
+
"Antarctica": []
|
|
30906
|
+
},
|
|
30907
|
+
shade: true,
|
|
30908
|
+
dim: true,
|
|
30909
|
+
shift: true,
|
|
30910
|
+
bloom: true,
|
|
30911
|
+
whither: true,
|
|
30912
|
+
subStyles: [
|
|
30913
|
+
{
|
|
30914
|
+
backgroundColor: red,
|
|
30915
|
+
color: white,
|
|
30916
|
+
rollBackgroundColor: purple,
|
|
30917
|
+
rollColor: white,
|
|
30918
|
+
selectedBackgroundColor: white,
|
|
30919
|
+
selectedColor: red,
|
|
30920
|
+
selectedRollBackgroundColor: purple,
|
|
30921
|
+
selectedRollColor: white
|
|
30922
|
+
}, {
|
|
30923
|
+
backgroundColor: blue,
|
|
30924
|
+
color: white,
|
|
30925
|
+
rollBackgroundColor: pink,
|
|
30926
|
+
rollColor: white,
|
|
30927
|
+
selectedBackgroundColor: black,
|
|
30928
|
+
selectedColor: white,
|
|
30929
|
+
selectedRollBackgroundColor: pink,
|
|
30930
|
+
selectedRollColor: white
|
|
30931
|
+
}, {
|
|
30932
|
+
backgroundColor: green,
|
|
30933
|
+
color: white,
|
|
30934
|
+
rollBackgroundColor: brown,
|
|
30935
|
+
rollColor: white,
|
|
30936
|
+
selectedBackgroundColor: black,
|
|
30937
|
+
selectedColor: white,
|
|
30938
|
+
selectedRollBackgroundColor: white,
|
|
30939
|
+
selectedRollColor: black
|
|
30940
|
+
}
|
|
30941
|
+
]
|
|
30942
|
+
};
|
|
30943
|
+
|
|
30944
|
+
const list = new List({
|
|
30945
|
+
list: accordionData,
|
|
30946
|
+
titleBar: "PLACES",
|
|
30947
|
+
titleBarBackgroundColor: orange,
|
|
30948
|
+
titleBarColor: white,
|
|
30949
|
+
titleBarHeight: 40,
|
|
30950
|
+
scrollBarActive: false,
|
|
30951
|
+
currentSelected: false,
|
|
30952
|
+
indent: 20,
|
|
30953
|
+
height: 650,
|
|
30954
|
+
viewNum: 13.5,
|
|
30955
|
+
boundary: new Boundary(0, 0, W - 200, H - 200),
|
|
30956
|
+
borderWidth: -1,
|
|
30957
|
+
shadowBlur: -1,
|
|
30958
|
+
backdropColor: F.color,
|
|
30959
|
+
})
|
|
30960
|
+
.loc(100, 90)
|
|
30961
|
+
.tap(()=>{
|
|
30962
|
+
const currentID = list.selected.listZID;
|
|
30963
|
+
const currentText = list.currentValue;
|
|
30964
|
+
const parentID = list.tree.getParent(currentID);
|
|
30965
|
+
let parentText;
|
|
30966
|
+
if (parentID) parentText = list.tree.getData(parentID).obj;
|
|
30967
|
+
zog(currentID, currentText, parentID, parentText);
|
|
30968
|
+
});
|
|
30969
|
+
END EXAMPLE
|
|
30970
|
+
|
|
30873
30971
|
PARAMETERS
|
|
30874
30972
|
** supports DUO - parameters or single object with properties below
|
|
30875
30973
|
** supports OCT - parameter defaults can be set with STYLE control (like CSS)
|
|
@@ -31072,6 +31170,8 @@ accordionIndex - read only index of the selected item inside an accordion otherw
|
|
|
31072
31170
|
selected - gets the current selected list object (ie. a Button)
|
|
31073
31171
|
use selected.checkBox to access the selected CheckBox if checkBox parameter is true
|
|
31074
31172
|
if custom objects are in the list then use selected.content to access the custom object
|
|
31173
|
+
list.selected.listZID will give the list id in the tree hierarchy
|
|
31174
|
+
list.tree.getData(list.selected.listZID).obj.text would get the text of the button - or just use list.currentValue
|
|
31075
31175
|
currentValue - gets or sets the current value - in setting, it matches the first label that has the value anywhere in it
|
|
31076
31176
|
text - gets or sets the current selected label text
|
|
31077
31177
|
label - gets current selected label object
|
|
@@ -41434,7 +41534,7 @@ continuous - (default false) set to true to force nodes to only be made from the
|
|
|
41434
41534
|
startIndex - (default null) set to a point index to force connectors to start at that node
|
|
41435
41535
|
all other nodes will have there noMouse() set - also see continous
|
|
41436
41536
|
duplicateLine - (default true) set to false to not allow multiple lines between the same connectors
|
|
41437
|
-
deleteNode - (default true) set to false to not allow nodes to be deleted by holding or doubleclicking and delete key
|
|
41537
|
+
deleteNode - (default true) set to false to not allow nodes to be deleted by holding or doubleclicking and delete or backspace key
|
|
41438
41538
|
dblclick - (default true) set to false to not allow nodes to be selected by doubleclicking
|
|
41439
41539
|
selected nodes can be moved together
|
|
41440
41540
|
selecting a node selects its children unless the ctrl key is held at which point it will not select children
|
|
@@ -41864,7 +41964,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
41864
41964
|
if (!zot(startIndex)) that.setAvailableIndexes(startIndex);
|
|
41865
41965
|
|
|
41866
41966
|
that.keyEvent = function (e) {
|
|
41867
|
-
if (deleteNode && e.keyCode == 46) { // delete
|
|
41967
|
+
if (deleteNode && (e.keyCode == 46 || e.key == "Backspace")) { // delete
|
|
41868
41968
|
zim.loop(selectedList, function (obj) {
|
|
41869
41969
|
if (obj && obj.parent) removeNode(obj);
|
|
41870
41970
|
});
|
|
@@ -44270,6 +44370,7 @@ wrap - (default true) set to false to stop the textarea from wrapping (css white
|
|
|
44270
44370
|
maxLength - (default null) set to a number to limit the number of characters in the textarea
|
|
44271
44371
|
frame - (default the zdf) a reference to the Frame (to scale and position the HTML tag)
|
|
44272
44372
|
expand - (default 20) hit area around background to count as a press on TextArea - handy for dragging as HTML tag area will override mouse on canvas
|
|
44373
|
+
keyboardShift - (default false) set to true to lift stage at least 1/4 height or up to textArea y/2 to raise textArea above keyboard
|
|
44273
44374
|
style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
|
|
44274
44375
|
group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
|
|
44275
44376
|
inherit - (default null) used internally but can receive an {} of styles directly
|
|
@@ -46746,6 +46847,8 @@ Chainable function that sets the object's cursor to the type provided - same as
|
|
|
46746
46847
|
|
|
46747
46848
|
NOTE: if using drag(), it will set its own cursor, so use the dragCursor parameter in that case.
|
|
46748
46849
|
|
|
46850
|
+
NOTE: there are also custom cursors as the cursors property of Frame.
|
|
46851
|
+
|
|
46749
46852
|
EXAMPLE
|
|
46750
46853
|
const circle = new Circle(10, red).center().cur(); // "pointer"
|
|
46751
46854
|
circle.on("click", ()=>{zog("yes");});
|
|
@@ -47518,6 +47621,7 @@ RETURNS obj for chaining
|
|
|
47518
47621
|
|
|
47519
47622
|
if (zot(obj) || !obj.on) return;
|
|
47520
47623
|
|
|
47624
|
+
|
|
47521
47625
|
var DA = zim.DRAGALL;
|
|
47522
47626
|
if (WW.DRAGALL != null) DA = WW.DRAGALL;
|
|
47523
47627
|
if (zot(all) && zot(currentTarget)) all = DA;
|
|
@@ -50936,9 +51040,9 @@ const physics = new Physics(0);
|
|
|
50936
51040
|
// create physics objects using the addPhysics() method
|
|
50937
51041
|
const circle = new Circle(50,blue,grey).center().addPhysics({bounciness:1.1});
|
|
50938
51042
|
|
|
50939
|
-
// make sure to centerReg() any rectangular objects
|
|
50940
|
-
const rect = new Rectangle(30,400).
|
|
50941
|
-
const tri = new Triangle(150,150,150,green,grey).
|
|
51043
|
+
// make sure to reg(CENTER) or centerReg() any rectangular objects
|
|
51044
|
+
const rect = new Rectangle(30,400).reg(CENTER).pos(70,0,LEFT,CENTER).addPhysics(false); // static - do not move
|
|
51045
|
+
const tri = new Triangle(150,150,150,green,grey).pos(200,0,LEFT,CENTER).addPhysics({linear:10}); // does not slide easily
|
|
50942
51046
|
|
|
50943
51047
|
// turn on dragging
|
|
50944
51048
|
physics.drag(); // note: to add a boundary use the borders parameter of Physics()
|
|
@@ -55292,6 +55396,11 @@ RETURNS target for chaining
|
|
|
55292
55396
|
checkTIME(totalTime, timeType, 40);
|
|
55293
55397
|
if (!zot(totalTime)) target.wiggleTimeout = setTimeout(function() {
|
|
55294
55398
|
target.stopAnimate(id);
|
|
55399
|
+
if (endOnStart) {
|
|
55400
|
+
var obj = {};
|
|
55401
|
+
obj[property]=zim.Pick.choose(baseAmount);
|
|
55402
|
+
zim.animate({target:target, obj:obj, time:0});
|
|
55403
|
+
}
|
|
55295
55404
|
target.dispatchEvent("wigglestop");
|
|
55296
55405
|
}, totalTime*(timeType=="s"?1000:1));
|
|
55297
55406
|
|
|
@@ -56290,7 +56399,10 @@ Older versions returned the mask shape - the mask shape can now be accessed by o
|
|
|
56290
56399
|
var m;
|
|
56291
56400
|
function apply() {
|
|
56292
56401
|
if (dynamic && (!stage || !mask.stage)) return obj;
|
|
56293
|
-
if (m
|
|
56402
|
+
if (m) {
|
|
56403
|
+
if (m.dispose) m.dispose(); // will remove
|
|
56404
|
+
else mask.removeChildAt(0);
|
|
56405
|
+
}
|
|
56294
56406
|
m = null;
|
|
56295
56407
|
obj.zimMask = mask.zimMask = m = mask.shape.clone();
|
|
56296
56408
|
zim.copyMatrix(m, mask);
|
|
@@ -57318,7 +57430,7 @@ EXAMPLE
|
|
|
57318
57430
|
// setting TIMECHECK to true will test for any time over 10 as that may be ms
|
|
57319
57431
|
|
|
57320
57432
|
TIMECHECK = true;
|
|
57321
|
-
new Circle().center().wiggle("x", 100,200, 2000, 4000); // will give warning in console about time not being in
|
|
57433
|
+
new Circle().center().wiggle("x", 100,200, 2000, 4000); // will give warning in console about time not being in ms
|
|
57322
57434
|
END EXAMPLE
|
|
57323
57435
|
--*///+29.45
|
|
57324
57436
|
zim.TIMECHECK = false;
|
|
@@ -58391,6 +58503,7 @@ you can define multiple pages objects add and remove pages objects as needed
|
|
|
58391
58503
|
|
|
58392
58504
|
var swipeEvent = this.swipe.on("swipe", function(e) {
|
|
58393
58505
|
if (!that.active) return;
|
|
58506
|
+
if (!that.parent) return;
|
|
58394
58507
|
var direction = e.currentTarget.direction;
|
|
58395
58508
|
if (direction == "none") return;
|
|
58396
58509
|
// swap direction (swipe up means move down)
|
|
@@ -70135,8 +70248,8 @@ EXAMPLE
|
|
|
70135
70248
|
const physics = new Physics(0);
|
|
70136
70249
|
const circle = new Circle(50,blue,grey).center().addPhysics({restitution:1.1}); // how bouncy
|
|
70137
70250
|
// make sure to reg(CENTER) or centerReg() any rectangular objects
|
|
70138
|
-
const rect = new Rectangle(30,400).reg(CENTER).pos(70).addPhysics(false); // static - do not move
|
|
70139
|
-
const tri = new Triangle(150,150,150,green,grey).
|
|
70251
|
+
const rect = new Rectangle(30,400).reg(CENTER).pos(70,0,LEFT,CENTER).addPhysics(false); // static - do not move
|
|
70252
|
+
const tri = new Triangle(150,150,150,green,grey).pos(200,0,LEFT,CENTER).addPhysics({linear:10}); // does not slide easily
|
|
70140
70253
|
physics.drag(); // note: to add a boundary use the borders parameter of Physics()
|
|
70141
70254
|
// test to see if circle hits rectangle
|
|
70142
70255
|
// contact callback function receives ZIM object (and physics body as next param)
|
|
@@ -78824,21 +78937,22 @@ EXAMPLE
|
|
|
78824
78937
|
// ****** note, the app must be interacted with before sound can play
|
|
78825
78938
|
const synth = new Synth();
|
|
78826
78939
|
new Button({label:"START"}).center().tap(()=>{
|
|
78827
|
-
synth.play(
|
|
78940
|
+
synth.play(0,...[,0,-1500,.3,.3,1.15,,1.01,2.37,-7.65,1100,.05,2,,-0.1,.07,5e-4]); // magical arrival
|
|
78828
78941
|
});
|
|
78829
78942
|
// This code came from here: https://zzfx.3d2k.com
|
|
78830
78943
|
// Note - it will have zzfx() and you want synth.play() - so copy what is in the brackets.
|
|
78831
|
-
//
|
|
78944
|
+
// **** - but put a 0 for the pan before their arguments (or a number from -1 to 1 for pan)
|
|
78945
|
+
// zzfx(0,...[,0,-1500,.3,.3,1.15,,1.01,2.37,-7.65,1100,.05,2,,-0.1,.07,5e-4]);
|
|
78832
78946
|
|
|
78833
78947
|
// Note - above is ES6 - otherwise in ES5:
|
|
78834
|
-
synth.play(null,0,-1500,.3,.3,1.15,null,1.01,2.37,-7.65,1100,.05,2,null,-0.1,.07,5e-4); // magical arrival
|
|
78948
|
+
synth.play(0,null,0,-1500,.3,.3,1.15,null,1.01,2.37,-7.65,1100,.05,2,null,-0.1,.07,5e-4); // magical arrival
|
|
78835
78949
|
END EXAMPLE
|
|
78836
78950
|
|
|
78837
78951
|
EXAMPLE
|
|
78838
78952
|
// play() example with event for complete
|
|
78839
78953
|
const synth = new Synth();
|
|
78840
78954
|
const circle = new Circle(50,blue).center().tap(function () {
|
|
78841
|
-
var synthSound = synth.play(
|
|
78955
|
+
var synthSound = synth.play(0,...[,,229,.04,.04,.47,,.84,7.85,,,,,.2,,.05]);
|
|
78842
78956
|
synthSound.on("complete", ()=>{
|
|
78843
78957
|
circle.removeFrom();
|
|
78844
78958
|
S.update();
|
|
@@ -90133,8 +90247,8 @@ const ask = new CamAsk().show(yes=>{
|
|
|
90133
90247
|
const camMotion = new CamMotion({
|
|
90134
90248
|
visualizerColor:[green,orange,yellow,red,blue,purple,pink],
|
|
90135
90249
|
visualizerBaseColor:clear,
|
|
90136
|
-
visualizerScale:
|
|
90137
|
-
visualizerBaseScale:
|
|
90250
|
+
visualizerScale:6,
|
|
90251
|
+
visualizerBaseScale:1
|
|
90138
90252
|
}).center();
|
|
90139
90253
|
|
|
90140
90254
|
// Optionally adjust the circles
|