zimjs 17.0.3 → 17.0.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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/zim.js +123 -56
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "17.0.3",
3
+ "version": "17.0.4",
4
4
  "type": "module",
5
5
  "main": "./src/zim.js",
6
6
  "types": "./ts-src/typings/zim",
package/src/zim.js CHANGED
@@ -9457,7 +9457,7 @@ normalize(prop, from, from2, min, max, factor, clamp) - sets a ratio property (1
9457
9457
  setting normalize("reg", CENTER) will do both horizontal and vertical to the container dimensions.
9458
9458
  If this is not desired, use container.loop(item=>{item.reg(item._orX, item._orY, true)});
9459
9459
  to set the registration point back but still keep the ratio property
9460
- USAGE: the ratio property can be used by animate() with sequenceRate to set the rate of an animation based on ratio
9460
+ USAGE: the ratio property can be used by animate() with sequenceRatio to set the rate of an animation based on ratio
9461
9461
  Or the ratio property can be used directly - for instance, to set a scale based on a distance from somewhere
9462
9462
  Or as another example, set the alpha based on the rotation of a shape in the container
9463
9463
  specialColor(colorCommand, colorObject) - used internally by ZIM Shapes
@@ -9487,8 +9487,8 @@ height - gets or sets the height. Setting the height will scale the width to kee
9487
9487
  widthOnly - gets or sets the width. This sets only the width and may change the aspect ratio of the object
9488
9488
  heightOnly - gets or sets the height. This sets only the height and may change the aspect ratio of the object
9489
9489
  ratio - get a ratio set by the Container normalize method() - or Tile itemRegX, itemRegY parameters
9490
- this will probably be a value from 1 to 0 as to how close the property is the end specified in the from parameter of normalize()
9491
- a value of 1 is the closest and a value of 0 is the farthest - see the normalize() method for details
9490
+ this will probably be a value from 1 to 0 as to how close the property is the end specified in the from parameter of normalize()
9491
+ a value of 1 is the closest and a value of 0 is the farthest - see the normalize() method for details
9492
9492
  normalized - get if the container has been normalized - see normalized parameter
9493
9493
  draggable - set to true for a default drag() and false for a noDrag()
9494
9494
  level - gets or sets the level of the object in its parent container (or the stage) - a property for parent.getChildIndex() and parent.setChildIndex()
@@ -14317,15 +14317,15 @@ dashed - (default false) set to true for dashed border (if borderWidth or border
14317
14317
  percent - (default 100) set to a percentage of a circle (arc) - registration stays at radius center, bounds shrink to arc
14318
14318
  percentClose - (default true) set to false to not close the border of a circle with percent set
14319
14319
  percentArc - (default false) set to a percent to make moon shapes - must have percent turned on
14320
- the value is the distance the arc-making circle is placed from the original circle's edge
14321
- this distance is given as a percentage of the original circle's radius
14322
- so if percentArc is set to 0 then the arc-making circle is at the radius (the edge) of the original circle
14323
- if the percentArc is set to 50 then the arc-making circle is half the radius outside the original radius and the arc is less
14324
- if the percentArc is set to -50 then the arc-making circle is half the radius inside the original radius and the arc is more
14325
- Note, due to canvas winding, the arc will not do very thin cresents as expected
14326
- instead once the inner arc is as wide as the outer arc, it makes a straight line
14327
- for thin crecents, overlap the circle with a circle that matches the background color
14328
- or if the background is an image, etc. then mask a clone of the background with the arc circle
14320
+ the value is the distance the arc-making circle is placed from the original circle's edge
14321
+ this distance is given as a percentage of the original circle's radius
14322
+ so if percentArc is set to 0 then the arc-making circle is at the radius (the edge) of the original circle
14323
+ if the percentArc is set to 50 then the arc-making circle is half the radius outside the original radius and the arc is less
14324
+ if the percentArc is set to -50 then the arc-making circle is half the radius inside the original radius and the arc is more
14325
+ Note, due to canvas winding, the arc will not do very thin cresents as expected
14326
+ instead once the inner arc is as wide as the outer arc, it makes a straight line
14327
+ for thin crecents, overlap the circle with a circle that matches the background color
14328
+ or if the background is an image, etc. then mask a clone of the background with the arc circle
14329
14329
  strokeObj - (default {caps:"butt", joints:"miter", miterLimit:10, ignoreScale:false}) set to adjust stroke properties
14330
14330
  // note, not all applicable to a Circle - perhaps just ignoreScale...
14331
14331
  caps options: "butt", "round", "square" or 0,1,2
@@ -14474,8 +14474,18 @@ zim.Circle = function(radius, color, borderColor, borderWidth, dashed, percent,
14474
14474
  var dY = Math.cos(p*Math.PI/180)*that._radius;
14475
14475
  if (!zot(percentArc)) {
14476
14476
  var r2 = Math.sqrt(Math.pow(dX,2) + Math.pow((that._radius+dY)+percentArc/100*that._radius,2));
14477
- var a1 = Math.asin(dX/r2);
14478
- g.arc(0, that._radius+percentArc/100*that._radius, r2, (-90*zim.RAD+a1), (-90*zim.RAD-a1), true);
14477
+ if (percentArc >= 0) {
14478
+ var a1 = Math.asin(dX/r2);
14479
+ var y2 = that._radius+percentArc/100*that._radius;
14480
+ var a2 = -90*zim.RAD+a1;
14481
+ var a3 = -90*zim.RAD-a1;
14482
+ g.arc(0, y2, r2, a2, a3, true);
14483
+ } else {
14484
+ // var y3 = dY - Math.sqrt(Math.pow(r2, 2) - Math.pow(dX, 2));
14485
+ // var a2 = Math.acos(dX/r2);
14486
+ // var a3 = 180*RAD - a2;
14487
+ // g.arc(0, y3, r2, a2, a3, false);
14488
+ }
14479
14489
  }
14480
14490
  if (percentClose) g.cp();
14481
14491
  h = that._radius-dY;
@@ -20764,7 +20774,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
20764
20774
  if (color.type) that.color = color;
20765
20775
  function drawShape(lengths, angles, anglesA, anglesB, anglesEnd, cross, crossColors, close) {
20766
20776
  that.removeAllChildren();
20767
-
20777
+
20768
20778
  var s = that.shape = new zim.Shape().addTo(that);
20769
20779
  that.colorCommand = s.c().f(color).command;
20770
20780
  if (color && color.type) that.specialColor(that.colorCommand, color, that);
@@ -28376,6 +28386,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28376
28386
  setTimeout(function(){
28377
28387
  if (content) {
28378
28388
  zim.drag({
28389
+ singleTouch:true,
28379
28390
  obj:content,
28380
28391
  currentTarget:true,
28381
28392
  axis:continuous,
@@ -30514,7 +30525,7 @@ text - |ZIM VEE| String for the the text of the label
30514
30525
  size - (default 36) the size of the font in pixels
30515
30526
  font - (default arial) the font or list of fonts for the text
30516
30527
  color - |ZIM VEE| (default dark) color of font
30517
- backgroundColor - |ZIM VEE| (default lighter) background color - set to -1 for no background
30528
+ backgroundColor - |ZIM VEE| (default lighter) background color - set to clear for no background
30518
30529
  borderColor - |ZIM VEE| (default null) the background stroke color
30519
30530
  borderWidth - (default null) thickness of the background border
30520
30531
  maxLength - (default null) set to limit the number of characters in the field
@@ -32680,8 +32691,9 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
32680
32691
  });
32681
32692
 
32682
32693
  that.dropDown = that.on("mousedown", function(e){
32694
+ // if (downItem) return;
32683
32695
  // make sure is item in list
32684
- downItem = checkItem = e.target;
32696
+ downItem = checkItem = e.target;
32685
32697
  // e.target can be something in the item - or the item
32686
32698
  // but custom List items are usually in a Container
32687
32699
  // so want to drag the item which is the child of the container that is in the List items
@@ -32779,32 +32791,36 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
32779
32791
  return; // next in loop
32780
32792
  }
32781
32793
  if (target.vertical) {
32782
- if (ghost.x > target.zgb.x && ghost.x < target.zgb.x + target.zgb.width) {
32783
- if (ghost.y < target.zgb.y) { // carefull - need to do these separately to turn off diamond
32784
- if (ghost.y > target.zgbtarget.zgb.y - 50) scrollUp(target, dropScrollSpeed);
32785
- else if (ghost.y > target.zgbtarget.zgb.y - 80) scrollUp(target, dropScrollSpeed*1.5);
32786
- onCheck = true;
32787
- } else if (ghost.y > target.zgbtarget.zgb.y + target.zgbtarget.zgb.height) {
32788
- if (ghost.y < target.zgbtarget.zgb.y + target.zgbtarget.zgb.height + 50) scrollDown(target, dropScrollSpeed);
32789
- else if (ghost.y < target.zgbtarget.zgb.y + target.zgbtarget.zgb.height + 80) scrollDown(target, dropScrollSpeed*1.5);
32790
- onCheck = true;
32791
- } else if (target.scrollInt) target.scrollInt.clear();
32792
- } else {
32793
- if (target.scrollInt) target.scrollInt.clear();
32794
+ if (target.scrollYMax > 0) {
32795
+ if (ghost.x > target.zgb.x && ghost.x < target.zgb.x + target.zgb.width) {
32796
+ if (ghost.y < target.zgb.y) { // carefull - need to do these separately to turn off diamond
32797
+ if (ghost.y > target.zgbtarget.zgb.y - 50) scrollUp(target, dropScrollSpeed);
32798
+ else if (ghost.y > target.zgbtarget.zgb.y - 80) scrollUp(target, dropScrollSpeed*1.5);
32799
+ onCheck = true;
32800
+ } else if (ghost.y > target.zgbtarget.zgb.y + target.zgbtarget.zgb.height) {
32801
+ if (ghost.y < target.zgbtarget.zgb.y + target.zgbtarget.zgb.height + 50) scrollDown(target, dropScrollSpeed);
32802
+ else if (ghost.y < target.zgbtarget.zgb.y + target.zgbtarget.zgb.height + 80) scrollDown(target, dropScrollSpeed*1.5);
32803
+ onCheck = true;
32804
+ } else if (target.scrollInt) target.scrollInt.clear();
32805
+ } else {
32806
+ if (target.scrollInt) target.scrollInt.clear();
32807
+ }
32794
32808
  }
32795
32809
  } else {
32796
- if (ghost.y > target.zgb.y && ghost.y < target.zgb.y + target.zgb.height) {
32797
- if (ghost.x < target.zgb.x) {
32798
- if (ghost.x > target.zgb.x - 50) scrollUp(target, dropScrollSpeed);
32799
- else if (ghost.x > target.zgb.x - 80) scrollUp(target, dropScrollSpeed*1.5);
32800
- onCheck = true;
32801
- } else if (ghost.x > target.zgb.x + target.zgb.width) {
32802
- if (ghost.x < target.zgb.x + target.zgb.width + 50) scrollDown(target, dropScrollSpeed);
32803
- else if (ghost.x < target.zgb.x + target.zgb.width + 80) scrollDown(target, dropScrollSpeed*1.5);
32804
- onCheck = true;
32805
- } else if (target.scrollInt) target.scrollInt.clear();
32806
- } else {
32807
- if (target.scrollInt) target.scrollInt.clear();
32810
+ if (target.scrollXMax > 0) {
32811
+ if (ghost.y > target.zgb.y && ghost.y < target.zgb.y + target.zgb.height) {
32812
+ if (ghost.x < target.zgb.x) {
32813
+ if (ghost.x > target.zgb.x - 50) scrollUp(target, dropScrollSpeed);
32814
+ else if (ghost.x > target.zgb.x - 80) scrollUp(target, dropScrollSpeed*1.5);
32815
+ onCheck = true;
32816
+ } else if (ghost.x > target.zgb.x + target.zgb.width) {
32817
+ if (ghost.x < target.zgb.x + target.zgb.width + 50) scrollDown(target, dropScrollSpeed);
32818
+ else if (ghost.x < target.zgb.x + target.zgb.width + 80) scrollDown(target, dropScrollSpeed*1.5);
32819
+ onCheck = true;
32820
+ } else if (target.scrollInt) target.scrollInt.clear();
32821
+ } else {
32822
+ if (target.scrollInt) target.scrollInt.clear();
32823
+ }
32808
32824
  }
32809
32825
  }
32810
32826
 
@@ -32907,9 +32923,13 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
32907
32923
 
32908
32924
  that.dispatchEvent("dropdown");
32909
32925
 
32910
- frame.stage.on("stagemouseup", function(){
32911
- frame.stage.off("stagemousemove", that.dropStage);
32912
-
32926
+ // frame.on("mouseupplus", smu, null, true); // once - but does not work with touch
32927
+ // that.pointerUpEvent = frame.on("pointerup", smu); // pointer does not have a once!
32928
+ frame.stage.on("stagemouseup", smu, null, true); // once - seems to be working on iframes, etc.
32929
+ function smu() {
32930
+ frame.off("pointerup", that.pointerUpEvent)
32931
+ frame.stage.off("stagemousemove", that.dropStage);
32932
+
32913
32933
  var empty = zim.loop(dropTargets, function(target) {
32914
32934
  if (target.type != "List") return;
32915
32935
  if (target.scrollInt) target.scrollInt.clear();
@@ -32923,33 +32943,36 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
32923
32943
  ghost.dispose();
32924
32944
  downItem.alpha = itemAlpha;
32925
32945
  ghost = null;
32926
- downPoint = null;
32946
+ downPoint = null;
32927
32947
 
32928
32948
  that.dropItem = downItem;
32929
32949
  that.dropList = target;
32930
32950
  that.dropNewIndex = target.dropReticleIndex;
32931
32951
  target.dropReticleIndex = null;
32932
-
32952
+ downItem = null;
32953
+
32933
32954
  return false;
32934
32955
  }
32935
32956
  });
32936
32957
 
32937
32958
  if (empty) {
32959
+ if (!downItem) return;
32938
32960
  var point = downItem.localToGlobal(itemPoint.x, itemPoint.y);
32939
32961
  ghost.animate({x:point.x, y:point.y}, .1, null, function() {
32940
32962
  ghost.dispose();
32941
32963
  downItem.alpha = itemAlpha;
32942
32964
  ghost = null;
32943
32965
  downPoint = null;
32966
+ downItem = null;
32944
32967
  })
32945
32968
  that.dropItem = downItem;
32946
32969
  that.dropList = that;
32947
32970
  that.dropNewIndex = that.dropIndex;
32948
32971
  }
32949
-
32950
32972
  that.dispatchEvent("dropup");
32973
+
32951
32974
 
32952
- }, null, true); // once
32975
+ }
32953
32976
  downItem.alp(.5);
32954
32977
  }
32955
32978
  });
@@ -53530,7 +53553,7 @@ sequenceCall - (default null) the function that will be called for each sequence
53530
53553
  Note: the value of the sequenceCall parameter will be the object that just ended animation unless there is a sequenceParams value
53531
53554
  sequenceParams - (default null) a parameter sent to the sequenceCall function
53532
53555
  sequenceReverse - |ZIM VEE| (default false) set to true to sequence through container or array backwards
53533
- sequenceRate - (default null) set to a value to adjust the rate based on item ratio property
53556
+ sequenceRatio - (default null) set to a value to adjust the rate based on item ratio property
53534
53557
  see https://zimjs.com/016/normalize.html
53535
53558
  see Container() ratio property and normalize() method which give a ratio property.
53536
53559
  This will automatically set sequence to 0 so that each item in the container (or tile) is animated individually
@@ -77265,11 +77288,11 @@ zim.Emitter = function(obj, width, height, interval, num, life, fade, shrink, wa
77265
77288
  var shrinkMe = particle.emitShape?false:that.shrink;
77266
77289
 
77267
77290
  var myLife = (container?container:particle).life = zik(that.life);
77291
+ that.traceFadeTime = Math.min(myLife, that.traceFadeTime);
77292
+ that.decayTime = Math.min(myLife, that.decayTime);
77268
77293
 
77269
77294
  if (that.decayTime > 0 && (that.fade || shrinkMe || (that.trace && that.traceFadeTime > 0))) {
77270
- // zog(pool)
77271
77295
  if (that.trace && that.traceFadeTime > 0) {
77272
- // zog("here")
77273
77296
  container.animate({
77274
77297
  obj:{alpha:0},
77275
77298
  time:that.traceFadeTime,
@@ -83013,7 +83036,15 @@ EVENTS
83013
83036
  also stores F.altKey, F.ctrlKey, F.metaKey, F.shiftKey
83014
83037
  Note: Alt ArrowLeft and Alt ArrowRight has been set to go back or forward in the browser history
83015
83038
  "keyup" - fired on keyup - just like the window keyup event with eventObject.keyCode, etc.
83039
+ "pointerdown", "pointermove", "pointerup", "pointerenter", "pointerleave" - mirrors DOM Pointer Events
83040
+ Note: the event object is a raw JavaScript event object, not a CreateJS event object
83041
+ so there is no clear() on the event object nor a once parameter for the on() method, instead use:
83042
+ const ev = F.on("pointerdown", ()=>{
83043
+ F.off("pointerdown", ev);
83044
+ // this will only run once
83045
+ });
83016
83046
  "mouseupplus" - fired when the browser window receives a mouseup event
83047
+ NOTE: deprecated - would suggest using pointerup instead of this
83017
83048
  also fired when the mouse enters the stage from an iFrame and is no longer down.
83018
83049
  Note there is no eventObject.
83019
83050
  ALSO see mouseupplusonly for only firing as mouse enters the stage from an iFrame and is no longer down.
@@ -83026,6 +83057,7 @@ EVENTS
83026
83057
  This will call the up function as the mouse comes back onto the stage
83027
83058
  if the mouse was down when leaving the stage and let up outside the iframe the canvas is in - goodness.
83028
83059
  "mouseuplusonly" - fired when the mouse comes back from an iframe (not holding the canvas)
83060
+ NOTE: deprecated - would suggest using pointerup instead of this
83029
83061
  and the mouse was down on the canvas and up in the iframe.
83030
83062
  this does not fire on a regular mouseup whereas the mouseupplus will.
83031
83063
  "wheel" - fired on mousewheel (Window wheel event)
@@ -83487,6 +83519,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
83487
83519
  canvas.releasePointerCapture(e.pointerId);
83488
83520
  that.dispatchEvent(e);
83489
83521
  });
83522
+
83490
83523
  canvas.addEventListener("pointermove", function(e) {
83491
83524
  that.dispatchEvent(e);
83492
83525
  });
@@ -83514,10 +83547,10 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
83514
83547
  }
83515
83548
  WW.removeEventListener("mousedown", leftEvent, true);
83516
83549
  WW.removeEventListener("mousemove", leftEvent, true);
83517
- WW.removeEventListener("mouseup", leftEvent);
83550
+ WW.removeEventListener("pointerup", leftEvent);
83518
83551
  WW.addEventListener("mousedown", leftEvent, true);
83519
83552
  WW.addEventListener("mousemove", leftEvent, true); // tell actual mousemove there was a mouseup
83520
- WW.addEventListener("mouseup", leftEvent); // give actual mouseup a chance to act
83553
+ WW.addEventListener("pointerup", leftEvent); // give actual mouseup a chance to act
83521
83554
  }
83522
83555
 
83523
83556
  function makeStage() {
@@ -84337,6 +84370,35 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
84337
84370
  if (assetHolder.sound) assetHolder.sound.pan = value;
84338
84371
  }
84339
84372
  });
84373
+ Object.defineProperty(assetHolder.proxy, 'paused', {
84374
+ get: function() {
84375
+ if (assetHolder.sound) return assetHolder.sound.paused;
84376
+ else return null;
84377
+ },
84378
+ set: function(value) {
84379
+ assetHolder.paused = value;
84380
+ if (assetHolder.sound) assetHolder.sound.paused = value;
84381
+ }
84382
+ });
84383
+ Object.defineProperty(assetHolder.proxy, 'position', {
84384
+ get: function() {
84385
+ if (assetHolder.sound) return assetHolder.sound.position;
84386
+ else return null;
84387
+ },
84388
+ set: function(value) {
84389
+ assetHolder.position = value;
84390
+ if (assetHolder.sound) assetHolder.sound.position = value;
84391
+ }
84392
+ });
84393
+ Object.defineProperty(assetHolder.proxy, 'duration', {
84394
+ get: function() {
84395
+ if (assetHolder.sound) return assetHolder.sound.duration;
84396
+ else return null;
84397
+ },
84398
+ set: function(value) {
84399
+ zogy("ZIM Aud - duration is read only");
84400
+ }
84401
+ });
84340
84402
  return assetHolder.proxy;
84341
84403
  }
84342
84404
  }
@@ -84355,9 +84417,10 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
84355
84417
  assetHolder.play = loaded.play;
84356
84418
  assetHolder.type = "Sound";
84357
84419
  assetHolder.src = loaded.src;
84358
- assetHolder.item = loaded.item;
84420
+ assetHolder.item = loaded.item;
84359
84421
  if (assetHolder.playParams) {
84360
84422
  assetHolder.sound = assetHolder.play.apply(null, assetHolder.playParams);
84423
+ assetHolder.proxy.sound = assetHolder.sound;
84361
84424
  if (assetHolder.volume != null) assetHolder.sound.volume = assetHolder.volume;
84362
84425
  if (assetHolder.pan != null) assetHolder.sound.pan = assetHolder.pan;
84363
84426
  assetHolder.sound.on("complete", function () {
@@ -85691,8 +85754,12 @@ ABSTRACT SOUND INSTANCE
85691
85754
  The return result of the play() makes a CreateJS AbstractSoundInstance
85692
85755
  var sound = Aud("sound.mp3").play(); // sound is an AbstractSoundInstance
85693
85756
  // note: if lazy-loaded then the result of a play() before the sound has loaded
85694
- // will be a proxy object with only volume and pan properties and will dispatch a complete event
85695
- // methods, other properties and events will only be available on a play() after the sound is loaded
85757
+ // will be a proxy object with volume, pan, paused, position and duration properties and will dispatch a complete event
85758
+ // methods, other properties and events will only be available on a play() of the sound played after loaded
85759
+ // or if the sound is played before loaded, there will be a sound property added after loaded
85760
+ // that has the rest of the AbstractSoundInstance properties and methods
85761
+ // for instance, myLazyPlay.sound.muted or myLazyPlay.sound.stop()
85762
+ // If the sound were preloaded, then these would be myPreloadPlay.muted and myPreloadPlay.stop()
85696
85763
 
85697
85764
  METHODS (of AbstractSoundInstance)
85698
85765
  ** full docs here: https://www.createjs.com/docs/soundjs/classes/AbstractSoundInstance.html