zimjs 16.4.5 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/zim.js +125 -16
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "16.4.5",
3
+ "version": "16.4.6",
4
4
  "type": "module",
5
5
  "main": "./src/zim.js",
6
6
  "types": "./ts-src/typings/zim",
package/src/zim.js CHANGED
@@ -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
- that.cjsContainer_cache(a-margin,b-margin,c+margin*2,d+margin*2,scale,options,rtl,willReadFrequently);
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
- that.setBounds(a, b, c, d);
9114
- if (a!=bounds.x || b!=bounds.y || c!=bounds.width || d!=bounds.height) that.reg(a,b);
9115
- that.hitArea = new zim.Shape().f(black).dr(a-margin,b-margin,c+margin*2,d+margin*2);
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;
@@ -30872,6 +30883,91 @@ new List({
30872
30883
  }).resize(300).center()
30873
30884
  END EXAMPLE
30874
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
+
30875
30971
  PARAMETERS
30876
30972
  ** supports DUO - parameters or single object with properties below
30877
30973
  ** supports OCT - parameter defaults can be set with STYLE control (like CSS)
@@ -31074,6 +31170,8 @@ accordionIndex - read only index of the selected item inside an accordion otherw
31074
31170
  selected - gets the current selected list object (ie. a Button)
31075
31171
  use selected.checkBox to access the selected CheckBox if checkBox parameter is true
31076
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
31077
31175
  currentValue - gets or sets the current value - in setting, it matches the first label that has the value anywhere in it
31078
31176
  text - gets or sets the current selected label text
31079
31177
  label - gets current selected label object
@@ -41436,7 +41534,7 @@ continuous - (default false) set to true to force nodes to only be made from the
41436
41534
  startIndex - (default null) set to a point index to force connectors to start at that node
41437
41535
  all other nodes will have there noMouse() set - also see continous
41438
41536
  duplicateLine - (default true) set to false to not allow multiple lines between the same connectors
41439
- 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
41440
41538
  dblclick - (default true) set to false to not allow nodes to be selected by doubleclicking
41441
41539
  selected nodes can be moved together
41442
41540
  selecting a node selects its children unless the ctrl key is held at which point it will not select children
@@ -41866,7 +41964,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
41866
41964
  if (!zot(startIndex)) that.setAvailableIndexes(startIndex);
41867
41965
 
41868
41966
  that.keyEvent = function (e) {
41869
- if (deleteNode && e.keyCode == 46) { // delete
41967
+ if (deleteNode && (e.keyCode == 46 || e.key == "Backspace")) { // delete
41870
41968
  zim.loop(selectedList, function (obj) {
41871
41969
  if (obj && obj.parent) removeNode(obj);
41872
41970
  });
@@ -44272,6 +44370,7 @@ wrap - (default true) set to false to stop the textarea from wrapping (css white
44272
44370
  maxLength - (default null) set to a number to limit the number of characters in the textarea
44273
44371
  frame - (default the zdf) a reference to the Frame (to scale and position the HTML tag)
44274
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
44275
44374
  style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
44276
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)
44277
44376
  inherit - (default null) used internally but can receive an {} of styles directly
@@ -47522,6 +47621,7 @@ RETURNS obj for chaining
47522
47621
 
47523
47622
  if (zot(obj) || !obj.on) return;
47524
47623
 
47624
+
47525
47625
  var DA = zim.DRAGALL;
47526
47626
  if (WW.DRAGALL != null) DA = WW.DRAGALL;
47527
47627
  if (zot(all) && zot(currentTarget)) all = DA;
@@ -50940,9 +51040,9 @@ const physics = new Physics(0);
50940
51040
  // create physics objects using the addPhysics() method
50941
51041
  const circle = new Circle(50,blue,grey).center().addPhysics({bounciness:1.1});
50942
51042
 
50943
- // make sure to centerReg() any rectangular objects
50944
- const rect = new Rectangle(30,400).centerReg().pos(70).addPhysics(false); // static - do not move
50945
- const tri = new Triangle(150,150,150,green,grey).center().pos(200).addPhysics({linear:10}); // does not slide easily
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
50946
51046
 
50947
51047
  // turn on dragging
50948
51048
  physics.drag(); // note: to add a boundary use the borders parameter of Physics()
@@ -55296,6 +55396,11 @@ RETURNS target for chaining
55296
55396
  checkTIME(totalTime, timeType, 40);
55297
55397
  if (!zot(totalTime)) target.wiggleTimeout = setTimeout(function() {
55298
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
+ }
55299
55404
  target.dispatchEvent("wigglestop");
55300
55405
  }, totalTime*(timeType=="s"?1000:1));
55301
55406
 
@@ -56294,7 +56399,10 @@ Older versions returned the mask shape - the mask shape can now be accessed by o
56294
56399
  var m;
56295
56400
  function apply() {
56296
56401
  if (dynamic && (!stage || !mask.stage)) return obj;
56297
- if (m && m.dispose) m.dispose();
56402
+ if (m) {
56403
+ if (m.dispose) m.dispose(); // will remove
56404
+ else mask.removeChildAt(0);
56405
+ }
56298
56406
  m = null;
56299
56407
  obj.zimMask = mask.zimMask = m = mask.shape.clone();
56300
56408
  zim.copyMatrix(m, mask);
@@ -70140,8 +70248,8 @@ EXAMPLE
70140
70248
  const physics = new Physics(0);
70141
70249
  const circle = new Circle(50,blue,grey).center().addPhysics({restitution:1.1}); // how bouncy
70142
70250
  // make sure to reg(CENTER) or centerReg() any rectangular objects
70143
- const rect = new Rectangle(30,400).reg(CENTER).pos(70).addPhysics(false); // static - do not move
70144
- const tri = new Triangle(150,150,150,green,grey).center().pos(200).addPhysics({linear:10});
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
70145
70253
  physics.drag(); // note: to add a boundary use the borders parameter of Physics()
70146
70254
  // test to see if circle hits rectangle
70147
70255
  // contact callback function receives ZIM object (and physics body as next param)
@@ -78829,21 +78937,22 @@ EXAMPLE
78829
78937
  // ****** note, the app must be interacted with before sound can play
78830
78938
  const synth = new Synth();
78831
78939
  new Button({label:"START"}).center().tap(()=>{
78832
- synth.play(...[,0,-1500,.3,.3,1.15,,1.01,2.37,-7.65,1100,.05,2,,-0.1,.07,5e-4]); // magical arrival
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
78833
78941
  });
78834
78942
  // This code came from here: https://zzfx.3d2k.com
78835
78943
  // Note - it will have zzfx() and you want synth.play() - so copy what is in the brackets.
78836
- // zzfx(...[,0,-1500,.3,.3,1.15,,1.01,2.37,-7.65,1100,.05,2,,-0.1,.07,5e-4]);
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]);
78837
78946
 
78838
78947
  // Note - above is ES6 - otherwise in ES5:
78839
- 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
78840
78949
  END EXAMPLE
78841
78950
 
78842
78951
  EXAMPLE
78843
78952
  // play() example with event for complete
78844
78953
  const synth = new Synth();
78845
78954
  const circle = new Circle(50,blue).center().tap(function () {
78846
- var synthSound = synth.play(...[,,229,.04,.04,.47,,.84,7.85,,,,,.2,,.05]);
78955
+ var synthSound = synth.play(0,...[,,229,.04,.04,.47,,.84,7.85,,,,,.2,,.05]);
78847
78956
  synthSound.on("complete", ()=>{
78848
78957
  circle.removeFrom();
78849
78958
  S.update();