zimjs 16.4.1 → 16.4.3

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 +71 -35
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "16.4.1",
3
+ "version": "16.4.3",
4
4
  "type": "module",
5
5
  "main": "./src/zim.js",
6
6
  "types": "./ts-src/typings/zim",
package/src/zim.js CHANGED
@@ -2178,6 +2178,8 @@ If more data is required, use an AJAX library
2178
2178
  NOTE: async uses an r CGI key to send a random number to defeat cache.
2179
2179
  Do not send an r property
2180
2180
 
2181
+ SEE: https://codepen.io/danzen/pen/gNKQYY for a full example
2182
+
2181
2183
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
2182
2184
 
2183
2185
  EXAMPLE
@@ -2197,8 +2199,7 @@ async("https://zimjs.org/cdn/jsonp.php?api="+api+"&callback=async.getData", getD
2197
2199
  function getData(data) {
2198
2200
  zog(data); // data will be the JSON parsed object
2199
2201
  }
2200
- See a full example here: https://codepen.io/danzen/pen/gNKQYY
2201
- Here is the jsonp.php code if you would like to host:
2202
+ // Here is the jsonp.php code if you would like to host:
2202
2203
 
2203
2204
  <?php
2204
2205
  $api = $_GET["api"];
@@ -14740,8 +14741,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
14740
14741
 
14741
14742
  var poly = this.shape = new createjs.Shape();
14742
14743
  this.addChild(poly);
14743
- poly.rotation = -90;
14744
-
14744
+
14745
14745
  var g = poly.graphics;
14746
14746
  that.drawShape = function() {
14747
14747
  g.c();
@@ -14757,7 +14757,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
14757
14757
  if (that._dashed) that.borderDashedCommand = g.sd(Array.isArray(that._dashed)?that._dashed:[10, 10], that._dashedOffset).command;
14758
14758
  }
14759
14759
  }
14760
- g.dp(0,0,that._radius, that._sides, that._pointSize);
14760
+ g.dp(0,0,that._radius, that._sides, that._pointSize, -90);
14761
14761
  that.setBounds(-that._radius,-that._radius, that._radius*2, that._radius*2);
14762
14762
  };
14763
14763
  that.drawShape();
@@ -22482,6 +22482,17 @@ const letters = new LabelLetters("Label Letters", CENTER, "bottom", 5)
22482
22482
  });
22483
22483
  END EXAMPLE
22484
22484
 
22485
+ EXAMPLE
22486
+ new LabelLetters("and Radial(), LabelOnArc(), LabelLetters()")
22487
+ .center()
22488
+ .animate({
22489
+ from:true,
22490
+ props:{alpha:0},
22491
+ time:.01,
22492
+ sequence:.04
22493
+ });
22494
+ END EXAMPLE
22495
+
22485
22496
  PARAMETERS
22486
22497
  ** supports DUO - parameters or single object with properties below
22487
22498
  ** supports OCT - parameter defaults can be set with STYLE control (like CSS)
@@ -22544,6 +22555,7 @@ addChild(), removeChild(), addChildAt(), getChildAt(), contains(), removeAllChil
22544
22555
  PROPERTIES
22545
22556
  type - the name of the class as a String
22546
22557
  text - get the text of the original Label
22558
+ See: https://zimjs.com/zapp/Z_VSR9X for updating text
22547
22559
  labels - an array of ZIM Label objects for the letters
22548
22560
  numLetters - how many letters (same as numChildren)
22549
22561
 
@@ -25732,7 +25744,7 @@ EXAMPLE
25732
25744
  // good for games that need keyboard if the game is in an iFrame like the Editor or CodePen
25733
25745
  // NOTE: do not use the on("close", f) method as it will not receive an event
25734
25746
  // with keyboardAccess the events on the canvas are turned off and captured in an any iFrame
25735
- new Pane({content:"START", keyboardAccess:true}).show();
25747
+ new Pane({content:"START", keyboardAccess:true}).show(()=>{zog("Keys ready")});
25736
25748
  END EXAMPLE
25737
25749
 
25738
25750
  EXAMPLE
@@ -25783,7 +25795,7 @@ END EXAMPLE
25783
25795
 
25784
25796
  EXAMPLE
25785
25797
  // custom backing with ZIM Pizzazz import at top
25786
- // import zim from https://zimjs.org/cdn/02/zim_pizzazz
25798
+ // import zim from "https://zimjs.org/cdn/016/zim_pizzazz"
25787
25799
  new Pane({
25788
25800
  content:new Label({color:white, text:"STOP", size:50}),
25789
25801
  backing:makePattern({
@@ -25849,6 +25861,7 @@ keyboardAccess - (default false) set to true to adds a click through iframe to g
25849
25861
  this sets an invisible Frame keyboardMessage() that will close the pane and give key access to iFrames
25850
25862
  do not use if expecting interactive content in the Pane - it is for a start message only
25851
25863
  do not use on("close", f) as it will not be captured with keyboardAccess true
25864
+ instead, use the callback in show() to call a function on close
25852
25865
  style - (default true) set to false to ignore styles set with the STYLE - will receive original parameter defaults
25853
25866
  group - (default null) set to String (or comma delimited String) so STYLE can set default styles to the group(s) (like a CSS class)
25854
25867
  inherit - (default null) used internally but can receive an {} of styles directly
@@ -30527,6 +30540,8 @@ zim.TextInput.LabelInput = function(text, size, maxLength, password, selectionCo
30527
30540
  this.hiddenInput.style.width = "1px";
30528
30541
  this.hiddenInput.style.height = "1px";
30529
30542
  this.hiddenInput.style.fontSize = "1px";
30543
+
30544
+ // this.hiddenInput.style.direction = rtl?"rtl":"ltr";
30530
30545
 
30531
30546
  this.onFocus = function() {
30532
30547
  if (this.stage) frame = this.stage.frame;
@@ -41392,12 +41407,12 @@ dropArray - (defult null) with "on" or "single" dropType and NOT linear - specif
41392
41407
  if "single" is set then only one line can be drawn
41393
41408
  also see dropIndex and dropArray for each node and the targetNode property
41394
41409
  each time a connection is made, a new node is created - these will inherit the dropIndex and dropArray from a targetNode
41395
- and if the latestNode's dropArray and its lineArray are the same and the duplicateLines is false then a "blocked" event is dispatched
41410
+ and if the latestNode's dropArray and its lineArray are the same and the duplicateLine is false then a "blocked" event is dispatched
41396
41411
  continuous - (default false) set to true to force nodes to only be made from the last node
41397
41412
  all other nodes will have their noMouse() set - also see startIndex - also see linear for doing points in order
41398
41413
  startIndex - (default null) set to a point index to force connectors to start at that node
41399
41414
  all other nodes will have there noMouse() set - also see continous
41400
- duplicateLines - (default true) set to false to not allow multiple lines between the same connectors
41415
+ duplicateLine - (default true) set to false to not allow multiple lines between the same connectors
41401
41416
  deleteNode - (default true) set to false to not allow nodes to be deleted by holding or doubleclicking and delete key
41402
41417
  dblclick - (default true) set to false to not allow nodes to be selected by doubleclicking
41403
41418
  selected nodes can be moved together
@@ -41487,11 +41502,11 @@ node - the DisplayObject used to make the connector nodes
41487
41502
  dropArray - get or set the array of dropIndexes that this node can connect to
41488
41503
  this will get transfered from a targerNode
41489
41504
  and if the dropArray and the lineArray are the same
41490
- and the duplicateLines is false then a "blocked" event is dispatched
41505
+ and the duplicateLine is false then a "blocked" event is dispatched
41491
41506
  lineArray - get an array of indexes to other node connections
41492
41507
  this will get transfered to a targetNode
41493
41508
  and if the lineArray and dropArray are the same
41494
- and the duplicateLines is false then a "blocked" event is dispatched
41509
+ and the duplicateLine is false then a "blocked" event is dispatched
41495
41510
  line - the Line object used to make the connector lines
41496
41511
  the line objects also have these added properties:
41497
41512
  node - a reference to the node at the start of the line
@@ -41529,7 +41544,7 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
41529
41544
  EVENTS
41530
41545
  dispatches a "connection" event if a new node is made and lastNode property is set to the new node
41531
41546
  dispatches a "noconnection" event if the connector is dropped and no new node is made
41532
- dispatches a "blocked" event of duplicateLines is false and continuous is true and there are no more connections available
41547
+ dispatches a "blocked" event of duplicateLine is false and continuous is true and there are no more connections available
41533
41548
  this will happen if the latestNode's dropArray is the same as its linesArray (the order in the array does not matter)
41534
41549
  dispatches a "complete" event in linear mode when the connections are complete
41535
41550
 
@@ -41871,13 +41886,15 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
41871
41886
  var downIndex;
41872
41887
  function downNode(e, stepping, moving, ctrl) {
41873
41888
  var child = e.target;
41874
- if (zot(child)) return;
41889
+ if (zot(child)) return;
41890
+ // if (child.selected) return;
41875
41891
 
41876
41892
  if (moving) {
41877
41893
  child.selected = true;
41878
41894
  selectedList = [];
41879
41895
  that.selectNode(child, !ctrl);
41880
41896
  }
41897
+
41881
41898
 
41882
41899
  downIndex = child.nodeNum; // used in record()
41883
41900
  if (!linear && (!rootLock || child.creator) && dblclick && !stepping) {
@@ -41993,6 +42010,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
41993
42010
  parent.creations.push(child);
41994
42011
  that.latestNode = child;
41995
42012
 
42013
+ if (rootLock) checkRootLock(child);
42014
+
42015
+
41996
42016
  }
41997
42017
 
41998
42018
  function moveNode(e, stepping, moving, ctrl) {
@@ -51995,7 +52015,7 @@ animateCall - (default null) calls function every animation
51995
52015
  animateParams - (default target) parameters to send animateCall function
51996
52016
  sequence - (default 0) the delay time in seconds to run on children of a container or an array of target animations
51997
52017
  with the addition of ZIM VEE object to the target, you must noPick the array
51998
- for example, target = container or target = {noPick:[a,b,c]} and sequence = 1000
52018
+ for example, target = container or target = {noPick:[a,b,c]} and sequence = 1
51999
52019
  would run the animation on the first child and then 1 second later, run the animation on the second child, etc.
52000
52020
  or in the case of the array, on element a and then 1 second later, element b, etc.
52001
52021
  If the loop prop is true then sequenceCall below would activate for each loop
@@ -53244,6 +53264,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
53244
53264
  if (target.handlePath) target.handlePath();
53245
53265
  }
53246
53266
 
53267
+
53247
53268
  // PATH ANIMATION SETUP
53248
53269
  var pathObject,newPoint,locPoint,segments;
53249
53270
  if (!zot(obj.path) && obj.path.segmentPoints) {
@@ -53252,8 +53273,10 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
53252
53273
  if (target.type == "Pen") target.infinite = true;
53253
53274
  target.zimOnPath = true;
53254
53275
  if (zot(target.pathRatio)) target.pathRatio = 0;
53255
- if (obj.orient) {
53276
+ if (obj.orient===true) {
53256
53277
  obj.orient = obj.path;
53278
+ }
53279
+ if (obj.orient) {
53257
53280
  obj.startOrient = obj.rotation; // ?
53258
53281
  }
53259
53282
  pathObject = obj.path;
@@ -60481,7 +60504,6 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
60481
60504
  heights.push(totalY);
60482
60505
  //}
60483
60506
  currentCols = [];
60484
-
60485
60507
 
60486
60508
  if (bottomFull || fl) {
60487
60509
  o.pos(totalX+(o.marginRight?o.marginRight:0), totalY+(o.marginTop?o.marginTop:0), zim.RIGHT, fl?zim.TOP:zim.BOTTOM);
@@ -67811,7 +67833,7 @@ fromIDs - an object of from() properties in the form {prop1:[id1, id2], prop2:[i
67811
67833
  if (objs.length>0) {
67812
67834
  zim.loop(objs, function (obj) {
67813
67835
  ids = that.objIDs.at(obj);
67814
- if (ids.length>0) {
67836
+ if (ids && ids.length>0) {
67815
67837
  zim.loop(ids, function (id) {
67816
67838
  clearID(id, false);
67817
67839
  });
@@ -68195,7 +68217,7 @@ fromIDs - an object of from() properties in the form {prop1:[id1, id2], prop2:[i
68195
68217
  };
68196
68218
 
68197
68219
  this.clear = function() {
68198
- if (that.bindType == zim.LOCALSTORAGE) localStorage[that.connection] = null;
68220
+ if (that.bindType == zim.LOCALSTORAGE) localStorage.removeItem(that.connection);
68199
68221
  return that;
68200
68222
  };
68201
68223
 
@@ -68872,11 +68894,10 @@ mousedownIncludes - (default null) a single object or array of objects (aside fr
68872
68894
  The controller assumes everything in the container will not activate the mousedown
68873
68895
  This lets you activate interface elements without moving to them ;-)
68874
68896
  If for instance, a backing is used other than the stage, just pass in the backing to this parameter
68875
- See also the mousedownIncludes property and mousedownExcludes parameter and property
68897
+ See also the mousedownIncludes property
68876
68898
  The boundary is automatically added to mousedownIncludes
68877
68899
  If the container is provided and it has a backing property, this is added automatically to the mouseDownIncludes at the start
68878
68900
  The backing can be removed from the mousedownIncludes property with mc.mousedownIncludes.splice(mc.mousedownIncludes.indexOf(mc.container.backing, 1));
68879
- mousedownExcludes - (default null) an array of objects that the mousedown will not work on - overrides mousedownIncludes
68880
68901
  minPercentSpeed - (default 0) if target is an Accelerator, the percentSpeed at the left or top of the stage (depending on axis)
68881
68902
  minPercentSpeed - (default 100) if target is an Accelerator, the percentSpeed at the right or bottom of the stage (depending on axis)
68882
68903
  dampKeyup - (default .3) damping applied to slow down Accelerator with keydown
@@ -70118,7 +70139,7 @@ EXAMPLE
70118
70139
  // this is like a mousejoint similar to drag() but attached to an object rather than the mouse
70119
70140
  // so a physics object can follow a ZIM drag() or animate() or wiggle(), etc.
70120
70141
  // the original distance between the objects is maintained like a distance joint
70121
- // see https://zimjs.com/valentines/puppet.html
70142
+ // see https://zimjs.com/valentines/puppets.html
70122
70143
  // see https://zimjs.com/valentines/puppets2.html
70123
70144
  const physics = new Physics(0);
70124
70145
  const control = new Triangle().center().mov(0,-100).drag(); // or animate() or wiggle()
@@ -72915,7 +72936,7 @@ EXAMPLE
72915
72936
  STYLE = {borderColor:dark, borderWidth:2};
72916
72937
  const front = F.makeIcon().sca(2.5);
72917
72938
  const back = new Page(front.width, front.height, blue, green, 1);
72918
- const Label("ZIM Flipper").center(back);
72939
+ const label = new Label("ZIM Flipper").center(back);
72919
72940
  const card = new Flipper(front, back).center();
72920
72941
  END EXAMPLE
72921
72942
 
@@ -73008,6 +73029,10 @@ ALSO: see the CreateJS Easel Docs for Container properties, such as:
73008
73029
  x, y, rotation, scaleX, scaleY, regX, regY, skewX, skewY,
73009
73030
  alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, etc.
73010
73031
 
73032
+ ACTIONEVENT
73033
+ This component is affected by the general ACTIONEVENT setting
73034
+ The default is "mousedown" - if set to something else the component will act on click (press)
73035
+
73011
73036
  EVENTS
73012
73037
  dispatches a "flip" event when the fipper starts the flip
73013
73038
  dispatches a "flipped" event when the fipper ends the flip
@@ -73057,12 +73082,12 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
73057
73082
  var obj;
73058
73083
  if ((frontPress && !flipped) || (backPress && flipped)) {
73059
73084
  obj = (interactive && front.backing)?front.backing:front;
73060
- obj.on("mousedown", function() {spin(front,back);});
73085
+ obj.on((!zns?WW.ACTIONEVENT=="mousedown":zim.ACTIONEVENT=="mousedown")?"mousedown":"click", function() {spin(front,back);});
73061
73086
  obj.cur();
73062
73087
  }
73063
73088
  if ((backPress && !flipped) || (frontPress && flipped)) {
73064
73089
  obj = (interactive && back.backing)?back.backing:back;
73065
- obj.on("mousedown", function() {spin(back,front,-1);});
73090
+ obj.on((!zns?WW.ACTIONEVENT=="mousedown":zim.ACTIONEVENT=="mousedown")?"mousedown":"click", function() {spin(back,front,-1);});
73066
73091
  obj.cur();
73067
73092
  }
73068
73093
  front.oScale = front.scale;
@@ -82422,7 +82447,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
82422
82447
  }
82423
82448
  }
82424
82449
 
82425
- function svgDone(bitmap, params) {
82450
+ function svgDone(bitmap, params) {
82426
82451
  queue.loadAssetsCount--;
82427
82452
  var item = params.item;
82428
82453
  var asset = zim.assets[item.id] = bitmap;
@@ -82456,8 +82481,9 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
82456
82481
  preload.on("error", function(e) {queue.dispatchEvent(e); if (!queueOnly) that.dispatchEvent(e);});
82457
82482
  preload.on("fileload", function(e) {
82458
82483
  // for some reason, errors are not working on IMG and SVG from PreloadJS
82459
- // so check for rawResult - should really fix this in CreateJS
82460
- if (!e.result || ((e.result.nodeName=="IMG" || e.result.nodeName=="SVG") && !e.rawResult && xhr)) {
82484
+ // so check for rawResult - should really fix this in CreateJS
82485
+ if (!e.result || ((e.result.nodeName=="IMG" || e.result.nodeName=="SVG") && !e.rawResult && xhr)) {
82486
+ zog("here")
82461
82487
  var ev = new createjs.Event("error");
82462
82488
  ev = new createjs.Event("error");
82463
82489
  ev.item = e.item; // createjs preload item
@@ -82466,7 +82492,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
82466
82492
  ev = new createjs.Event("error");
82467
82493
  ev.item = e.item;
82468
82494
  that.dispatchEvent(ev);
82469
- } else {
82495
+ } else {
82470
82496
  var item = e.item;
82471
82497
  var type = e.item.type;
82472
82498
  var ext = item.id.match(re);
@@ -82530,7 +82556,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
82530
82556
  }
82531
82557
  } else if (type == "svg") {
82532
82558
  queue.loadAssetsCount++;
82533
- zim.svgToBitmap(e.result, svgDone, null, null, {svg:e.result, item:item, type:type, ext:ext});
82559
+ zim.svgToBitmap(e.result, svgDone, null, null, {svg:e.result, item:item, type:type, ext:ext});
82534
82560
  return;
82535
82561
  } else {
82536
82562
  asset = zim.assets[item.id] = e.result;
@@ -85966,7 +85992,7 @@ RETURNS - null
85966
85992
  --*///+83.27
85967
85993
  zim.svgToBitmap = function(svg, callback, width, height, params) {
85968
85994
  z_d("83.27");
85969
-
85995
+
85970
85996
  if (!zot(svg.draggable)) {
85971
85997
  // CreateJS seems to wrap up an SVG with loadAssets as an SVG object
85972
85998
  var parser = new DOMParser();
@@ -85977,8 +86003,10 @@ RETURNS - null
85977
86003
  }
85978
86004
 
85979
86005
  if (!XMLSerializer) {if (zon) {zogy("ZIM svgToBitmap() - sorry, not supported in Browser"); return;}}
85980
- var svgString = (typeof svg == "string") ? svg : new XMLSerializer().serializeToString(svg);
86006
+ var svgString = (typeof svg == "string") ? svg : new XMLSerializer().serializeToString(svg);
85981
86007
  if (svgString) {
86008
+ // https does not work
86009
+ svgString = svgString.replace(/https:\/\/www.w3/i, "http://www.w3");
85982
86010
  // seem to need width and height parameters in svg tag
85983
86011
  var first = svgString.split(">")[0];
85984
86012
  if (first.length>1) {
@@ -86001,19 +86029,27 @@ RETURNS - null
86001
86029
  svgString = svgString.replace(/svg /i, "svg width=\""+w+"\" height=\""+h+"\" ");
86002
86030
  }
86003
86031
  }
86004
- if (!svgString.match(/xmlns/i)) svgString = svgString.replace(/svg /i, "svg xmlns='https://www.w3.org/2000/svg' ");
86032
+ if (!svgString.match(/xmlns/i)) svgString = svgString.replace(/svg /i, "svg xmlns='http://www.w3.org/2000/svg' ");
86005
86033
  }
86006
86034
  var DOMURL = self.URL || self.webkitURL || self;
86035
+ var inte = setTimeout(function() {
86036
+ zogy("ZIM SVG() could not be made");
86037
+ callback(new zim.Bitmap(), params);
86038
+ DOMURL.revokeObjectURL(obu);
86039
+ }, 100);
86007
86040
  var img = new Image();
86008
86041
  img.onload = function() {
86042
+ clearTimeout(inte);
86009
86043
  var bitmap = new zim.Bitmap(img, width, height);
86010
86044
  callback(bitmap, params);
86011
86045
  DOMURL.revokeObjectURL(obu);
86012
- };
86046
+ };
86013
86047
  var obu;
86014
- if (document && document.Blob) obu = DOMURL.createObjectURL(new document.Blob([svgString], {type: "image/svg+xml"}));
86015
- else obu = DOMURL.createObjectURL(new Blob([svgString], {type: "image/svg+xml"}));
86048
+ if (document && document.Blob) {
86049
+ obu = DOMURL.createObjectURL(new document.Blob([svgString], {type: "image/svg+xml"}));
86050
+ } else obu = DOMURL.createObjectURL(new Blob([svgString], {type: "image/svg+xml"}));
86016
86051
  img.src = obu;
86052
+
86017
86053
  };//-83.27
86018
86054
 
86019
86055
  /*--