zimjs 19.1.0 → 19.1.1

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 +91 -43
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "19.1.0",
3
+ "version": "19.1.1",
4
4
  "type": "module",
5
5
  "main": "./src/zim.js",
6
6
  "types": "./ts-src/typings/zim",
package/src/zim.js CHANGED
@@ -75,7 +75,6 @@ var z_i; // iterator i in global namespace
75
75
  //////////////// ZIM WRAP //////////////
76
76
  // Zim Wrap creates global wrapper functions for less typing
77
77
 
78
-
79
78
  /*--
80
79
  zog(item1, item2, etc.) ~ log
81
80
 
@@ -12155,7 +12154,6 @@ group - (default null) set to String (or comma delimited String) so STYLE can se
12155
12154
  inherit - (default null) used internally but can receive an {} of styles directly
12156
12155
 
12157
12156
  METHODS
12158
- run(time, label, call, params, wait, waitedCall, waitedParams, loop, loopCount, loopWait, loopCall, loopParams, loopWaitCall, loopWaitParams, loopPick, rewind, rewindWait, rewindCall, rewindParams, rewindWaitCall, rewindWaitParams, rewindTime, rewindEase, startFrame, endFrame, frame, tweek, id, globalControl)
12159
12157
  The run() method animates the Sprite over an amount of time
12160
12158
  Would recommend this method over the CreateJS play() and gotoAndPlay()
12161
12159
  methods because the framerate for these get overwritten by other S.update() calls
@@ -14944,11 +14942,12 @@ EXAMPLE
14944
14942
  new Frame(FILL, 1024, 768, clear, clear, ready);
14945
14943
  function ready() {
14946
14944
  const fragment = `
14945
+ out vec4 fragColor;
14947
14946
  void main() {
14948
14947
  vec2 uv = gl_FragCoord.xy / iResolution.xy;
14949
14948
  vec3 color = 0.5 + 0.5 * cos(iTime + uv.xyx + vec3(0,2,4));
14950
- gl_FragColor = vec4(vec3(color), 1.0);
14951
- }
14949
+ fragColor = vec4(vec3(color), 1.0);
14950
+ }
14952
14951
  `;
14953
14952
  const shader = new zim.ShaderOverlay(W, H, fragment).center();
14954
14953
  shader.tag.style.zIndex = -50; // put shader beneath stage
@@ -24686,7 +24685,8 @@ zim.LabelOnArc = function(label, size, font, color, radius, flip, spacing, lette
24686
24685
  var rev = label.text.split("").reverse().join("");
24687
24686
  label.text = rev;
24688
24687
  }
24689
- letters = that.letters = new zim.Container(that.width, that.height).centerReg(that);
24688
+ zog(that.width, that.height)
24689
+ letters = that.letters = new zim.Container(100,100).center(that);
24690
24690
 
24691
24691
  that.numLetters = label.text.length;
24692
24692
  that.letterHeight = label.height;
@@ -24756,7 +24756,8 @@ zim.LabelOnArc = function(label, size, font, color, radius, flip, spacing, lette
24756
24756
  var letter = letters.getChildAt(i);
24757
24757
  // var amount = angles[i];
24758
24758
  lastAngle = letter.rotation = lastAngle + angles[i];
24759
- }
24759
+ }
24760
+ letters.setBounds(null);
24760
24761
  }
24761
24762
 
24762
24763
  this.setProps = function(props) {
@@ -24799,6 +24800,9 @@ zim.LabelOnArc = function(label, size, font, color, radius, flip, spacing, lette
24799
24800
  }
24800
24801
  });
24801
24802
 
24803
+ // TODO - in ZIM 020 - add this line
24804
+ // that.setBounds(null);
24805
+
24802
24806
  if (style!==false) zim.styleTransforms(this, DS);
24803
24807
  this.clone = function() {
24804
24808
  return that.cloneProps(new zim.LabelOnArc(label, size, font, color, radius, flip, spacing, letterSpacing, angles, showCircle, arcColor, arcBorderColor, arcBorderWidth, radiusSpread, rtl, style, this.group, inherit));
@@ -29216,10 +29220,9 @@ content - gives access to the content provided as a parameter to the Panel()
29216
29220
  buttons - an array of the Button objects if provided
29217
29221
  config - the original content config object {}
29218
29222
  panelHeight - get and set the height of the panel without scaling it as height does (for width, remake the Panel object)
29219
- titleBar - access to the titleBar container
29223
+ titleBar - access to the titleBar container - which also has a backing property
29220
29224
  titleBarlabel - access to the label of the current panel
29221
29225
  text - access to the text of the current panel
29222
- titleBar - gives access to the titleBar Container - which also has a background property
29223
29226
  titleBarLabel - gives access to the titleBar label
29224
29227
  closeIcon - access to the close button
29225
29228
  collapseIcon - access to the ZIM Shape if there is a collapse triangle
@@ -37033,6 +37036,7 @@ barLength - (default 300) the length of the bar (the slider slides along its len
37033
37036
  barWidth - (default 3) the width of the bar (how fat the bar is)
37034
37037
  barColor - (default granite) the color of the bar (any CSS color)
37035
37038
  vertical - (default false) set to true to make slider vertical
37039
+ vertical will have a default value of max
37036
37040
  useTicks - (default false) set to true to show small ticks for each step (step > 0)
37037
37041
  tickColor - (default barColor) set the tick color if ticks are set
37038
37042
  tickStep - (default step - or 1 if no step and useTicks is true) set to adjust tick amount
@@ -37060,7 +37064,7 @@ keyArrowsV - (default true) use up and down arrows when keyArrows is true
37060
37064
  damp - (default null) set to value such as .1 to damp the slider value
37061
37065
  use with Ticker rather than "change" event - eg:
37062
37066
  Ticker.add(()=>{circle.x = slider.value;});
37063
- value - |ZIM VEE| (default min) a starting value for the slider
37067
+ value - |ZIM VEE| (default min for horizontal or max for vertical) a starting value for the slider
37064
37068
  expand - (default null or 10 for mobile) set to value to expand the interactive area of the slider button
37065
37069
  expandVertical - (default expand) set to value to expand the vertical interactive area of the slider button
37066
37070
  expandBar - (default 20 or 0 for horizontal) set to value to expand the interactive area of the slider bar
@@ -37227,7 +37231,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
37227
37231
  .sca(0,1).rot(vertical?-90:0).mov(vertical?-accentOffset-accentSize-barWidth/2:0, vertical?barLength:accentOffset+barWidth/2)
37228
37232
  .addTo(this);
37229
37233
  }
37230
- function drawAccent() {
37234
+ function drawAccent() {
37231
37235
  accent.sca((that.value-that.min)/Math.abs(that.max-that.min), 1);
37232
37236
  }
37233
37237
 
@@ -37348,7 +37352,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
37348
37352
  }
37349
37353
  }
37350
37354
 
37351
- var myValue = min;
37355
+ var myValue = vertical?max:min; // ZIM 019 patch
37352
37356
  var lastValue = 0; // does not include min so always starts at 0
37353
37357
  this.button = button;
37354
37358
  this.cur("pointer");
@@ -37695,6 +37699,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
37695
37699
 
37696
37700
 
37697
37701
  if (!zot(value)) that.value = value;
37702
+ if (accent) drawAccent();
37698
37703
 
37699
37704
  zim.setSwipe(this, false);
37700
37705
 
@@ -49241,7 +49246,7 @@ resize() - call the resize event if the scale or position of the Loader is chang
49241
49246
  Note: if the Frame itself changes location in the HTML document, call a F.update()
49242
49247
  this will then dispatch an update event to the Loader and it will resize()
49243
49248
  this is not needed if resizing the window or scrolling - see Frame update() method docs
49244
- save(content, filename, x, y, width, height, cached, cachedBounds, type, data, quality) - save a picture or text (supports ZIM DUO)
49249
+ save(content, filename, x, y, width, height, cached, cachedBounds, type, data, quality, remakeCache) - save a picture or text (supports ZIM DUO)
49245
49250
  content - the Display object to be saved such as a Container, Bitmap, etc.
49246
49251
  or text (or Label, TextInput, TextArea) or JSON or object for JSON
49247
49252
  if text or json, then x, y, width, height, cached, cachedBounds, data, and quality are ignored
@@ -49256,6 +49261,11 @@ save(content, filename, x, y, width, height, cached, cachedBounds, type, data, q
49256
49261
  otherwise save returns the object for chaining
49257
49262
  quality - (default .92) a number between 0 an 1 representing the quality of the saved image (jpeg)
49258
49263
  note, this parameter may be moved to before data in the next version of ZIM
49264
+ remakeCache - (default true) set to false if cached and do not want to recache due to using updateCache with blendmode
49265
+ BUT - probably want a backing color for blit art
49266
+ so recommend making a new Page(W,H,black) then add the art container to the backing and save the backing
49267
+ then add the art container back to the stage
49268
+ then do not set the remakeCache so it stays true and caches the page
49259
49269
 
49260
49270
  Button methods:
49261
49271
  setBacking(type, newBacking) - dynamically set any type of backing for button (if null removes backing for that type)
@@ -49586,11 +49596,12 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
49586
49596
  uploadTag.addEventListener("drop", uploadEvent);
49587
49597
  }
49588
49598
 
49589
- this.save = function(content, filename, x, y, width, height, cached, cachedBounds, type, data, quality) {
49599
+ this.save = function(content, filename, x, y, width, height, cached, cachedBounds, type, data, quality, remakeCache) {
49590
49600
 
49591
- var sig = "content, filename, x, y, width, height, cached, cachedBounds, type, data, quality";
49601
+ var sig = "content, filename, x, y, width, height, cached, cachedBounds, type, data, quality, remakeCache";
49592
49602
  var duo; if (duo = zob(that.save, arguments, sig)) return duo;
49593
49603
  if (zot(content)) content = frame.stage;
49604
+ if (zot(remakeCache)) remakeCache = true;
49594
49605
 
49595
49606
  if (type=="text") type = "txt";
49596
49607
  if (zot(type)) type = "png";
@@ -49632,15 +49643,16 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
49632
49643
  if (zot(height)) height = (content.getBounds && content.getBounds()) ? content.getBounds().height : frame.height;
49633
49644
  var cacheO = content.cacheCanvas;
49634
49645
 
49635
- content.cache(x, y, width, height);
49636
-
49646
+ if (remakeCache) content.cache(x, y, width, height);
49637
49647
 
49638
49648
  if (data) {
49639
49649
  var image = content.cacheCanvas.toDataURL('image/' + type, quality);
49640
- if (cached) {
49641
- if (cachedBounds) content.cache(cachedBounds.x, cachedBounds.y, cachedBounds.width, cachedBounds.height);
49642
- } else {
49643
- content.uncache();
49650
+ if (remakeCache) {
49651
+ if (cached) {
49652
+ if (cachedBounds) content.cache(cachedBounds.x, cachedBounds.y, cachedBounds.width, cachedBounds.height);
49653
+ } else {
49654
+ content.uncache();
49655
+ }
49644
49656
  }
49645
49657
  return image;
49646
49658
  }
@@ -49691,10 +49703,12 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
49691
49703
  // win.document.close();
49692
49704
 
49693
49705
  // }
49694
- if (cached || cacheO) {
49695
- if (cachedBounds) content.cache(cachedBounds.x, cachedBounds.y, cachedBounds.width, cachedBounds.height);
49696
- } else {
49697
- content.uncache();
49706
+ if (remakeCache) {
49707
+ if (cached || cacheO) {
49708
+ if (cachedBounds) content.cache(cachedBounds.x, cachedBounds.y, cachedBounds.width, cachedBounds.height);
49709
+ } else {
49710
+ content.uncache();
49711
+ }
49698
49712
  }
49699
49713
 
49700
49714
  return that;
@@ -58357,7 +58371,7 @@ sequenceCall - (default null) the function that will be called for each sequence
58357
58371
  sequenceParams - (default null) a parameter sent to the sequenceCall function
58358
58372
  sequenceReverse - |ZIM VEE| (default false) set to true to sequence through container or array backwards
58359
58373
  sequenceRatio - (default null) set to a value to adjust the rate based on item ratio property
58360
- see https://zimjs.com/016/normalize.html
58374
+ see https://zimjs.com/016/normalize.html
58361
58375
  see Container() ratio property and normalize() method which give a ratio property.
58362
58376
  This will automatically set sequence to 0 so that each item in the container (or tile) is animated individually
58363
58377
  the sequenceRate value will be multiplied by the item's ratio and then added to the rate (see rate parameter)
@@ -69790,7 +69804,6 @@ Beads
69790
69804
  zim class - extends a zim.Container which extends a createjs.Container
69791
69805
 
69792
69806
  DESCRIPTION
69793
-
69794
69807
  Beads adds objects around a Squiggle or Blob path.
69795
69808
  Different objects can be specified with ZIM VEE (Pick) values
69796
69809
  to put random or sequenced objects around path.
@@ -71831,6 +71844,7 @@ const camera = three.camera;
71831
71844
 
71832
71845
  const controls = new OrbitControls(camera, three.canvas);
71833
71846
 
71847
+ Note: put TextureActives above applying any TextureActive textures to three.js objects
71834
71848
  const textureActives = new TextureActives([panel, backing], THREE, three, renderer, scene, camera, controls, 1, 0, 1500);
71835
71849
 
71836
71850
  // can capture raydown, raymove, rayup, rayover and rayout
@@ -72085,6 +72099,8 @@ XR
72085
72099
  TextureActive will detect if XR (AR/VR) is being used and will use the suitable Raycaster
72086
72100
  Additional classes are provided with the ZIM Three helper library for controllers, movement and teleport
72087
72101
 
72102
+ NOTE: put the TextureActives object before applying any TextureActive textures to three.js objects
72103
+
72088
72104
  NOTE: for XR, a layer must be set so the controllers do not get in the way of interactivity
72089
72105
  so in the TextureActives() set layer:1 and when adding meshes use addMesh(mesh, 1)
72090
72106
 
@@ -72131,6 +72147,7 @@ const camera = three.camera;
72131
72147
 
72132
72148
  const controls = new OrbitControls(camera, three.canvas);
72133
72149
 
72150
+ Note: put TextureActives above applying any TextureActive textures to three.js objects
72134
72151
  const textureActives = new TextureActives([panel, backing], THREE, three, renderer, scene, camera, controls, 1, 0, 1500);
72135
72152
 
72136
72153
  // can capture raydown, raymove, rayup, rayover and rayout
@@ -76210,7 +76227,13 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
76210
76227
  pp.y < con.y || pp.y > con.y+con.height
76211
76228
  ) return;
76212
76229
  }
76213
- if (type == "mousedown") {
76230
+ if (type == "mousedown") {
76231
+
76232
+ // added ZIM 019 patch to not include objects outside container if provided unless in mousedownIncludes
76233
+ if (that.mouseDownIncludes || container) under = stage.getObjectUnderPoint(e.stageX, e.stageY, 1);
76234
+ if (container && under && under!=target && !container.contains(under)) {
76235
+ if (mousedownIncludes && mousedownIncludes.indexOf(under) == -1) return;
76236
+ }
76214
76237
  if (!Array.isArray(that.mousedownIncludes)) that.mousedownIncludes = [that.mousedownIncludes];
76215
76238
  if (that.mousedownIncludes.indexOf(container)<0) {
76216
76239
  for (i=0; i<container.numChildren; i++) {
@@ -76257,9 +76280,13 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
76257
76280
  if (type == "pressdrag" && !target.hitTestPoint(e.stageX/zim.scaX, e.stageY/zim.scaY)) return;
76258
76281
  moveCheck = false;
76259
76282
  if (!Array.isArray(that.mousedownIncludes)) that.mousedownIncludes = [that.mousedownIncludes];
76260
- var inCheck = false;
76261
-
76262
- if (that.mouseDownIncludes) under = stage.getObjectUnderPoint(e.stageX, e.stageY, 1);
76283
+ var inCheck = false;
76284
+
76285
+ // added ZIM 019 patch to not include objects outside container if provided unless in mousedownIncludes
76286
+ if (that.mouseDownIncludes || container) under = stage.getObjectUnderPoint(e.stageX, e.stageY, 1);
76287
+ if (container && under && under!=target && !container.contains(under)) {
76288
+ if (mousedownIncludes && mousedownIncludes.indexOf(under) == -1) return;
76289
+ }
76263
76290
 
76264
76291
  for (i=0; i<that.mousedownIncludes.length; i++) {
76265
76292
  if (under && that.mousedownIncludes[i].hitTestPoint && that.mousedownIncludes[i].hitTestPoint(e.stageX/zim.scaX, e.stageY/zim.scaY) && that.mousedownIncludes[i].contains(under)) {
@@ -76270,7 +76297,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
76270
76297
  for (i=0; i<container.numChildren; i++) {
76271
76298
  var child = container.getChildAt(i);
76272
76299
  // returning on first container?
76273
- if (that.mousedownIncludes.indexOf(child)==-1 && child.mouseEnabled && child.hitTestPoint && child.hitTestPoint(e.stageX/zim.scaX, e.stageY/zim.scaY)) return;
76300
+ if (that.mousedownIncludes.indexOf(child)==-1 && child.mouseEnabled && child.hitTestPoint && child.hitTestPoint(e.stageX/zim.scaX, e.stageY/zim.scaY)) return;
76274
76301
  }
76275
76302
  }
76276
76303
  var p = container.globalToLocal(mouseMoveOutside?e.rawX/zim.scaX:e.stageX/zim.scaX, mouseMoveOutside?e.rawY/zim.scaY:e.stageY/zim.scaY);
@@ -88103,25 +88130,45 @@ dispatches a "ready" event when the sound source is connected and the calculate(
88103
88130
  } else if (input.type == "SynthSound") {
88104
88131
  connectSource(input.gain);
88105
88132
  } else {
88106
- if (input.type && input.type == "sound") {zogy("ZIM SoundWave: pass in the result of a zim.asset('somesound').play() for the input"); return;}
88133
+ if (input.type && input.type == "sound") {zogy("ZIM SoundWave: pass in the result of an Aud('somesound').play() for the input"); return;}
88107
88134
  var audio,source;
88108
88135
  if (input.playbackResource) {
88109
- audio = input.playbackResource; // a playing zim.asset("somesound").play()
88110
- if (audio.mediaSourceNode) {
88111
- source = audio.mediaSourceNode;
88112
- } else {
88113
- source = audioContext.createMediaElementSource(audio);
88114
- }
88136
+ audio = input.playbackResource; // a playing Aud("somesound").play()
88137
+
88138
+ // ZIM 019 Patch - thanks Vishwas Gagrani for the report
88139
+ // if audio finishes cannot properly remove the source - bug in HTML 5 Audio
88140
+ // which caused errors if trying to do another SoundWave on the audio
88141
+ // so remember if already had a Soundwave
88142
+ // and need to use that audioContext and analyser
88143
+ if (audio.firstSource) {
88144
+ source = audio.firstSource;
88145
+ audioContext = audio.audioContext;
88146
+ analyser = audio.analyser;
88147
+ } else {
88148
+ if (audio.mediaSourceNode) {
88149
+ source = audio.mediaSourceNode;
88150
+ } else {
88151
+ source = audioContext.createMediaElementSource(audio);
88152
+ }
88153
+ }
88115
88154
  } else {
88116
88155
  audio = input; // a playing <audio> tag zid("soundTagID").play()
88117
- source = audioContext.createMediaElementSource(audio);
88118
- }
88156
+ if (audio.firstSource) {
88157
+ source = audio.firstSource;
88158
+ audioContext = audio.audioContext;
88159
+ analyser = audio.analyser;
88160
+ } else {
88161
+ source = audioContext.createMediaElementSource(audio);
88162
+ }
88163
+ }
88164
+ audio.firstSource = source;
88165
+ audio.audioContext = audioContext;
88166
+ audio.analyser = analyser;
88119
88167
  connectSource(source);
88120
88168
  }
88121
88169
  };
88122
88170
  this.setInput(input);
88123
88171
 
88124
-
88125
88172
  var steps;
88126
88173
  var lastSource;
88127
88174
 
@@ -88208,6 +88255,7 @@ dispatches a "ready" event when the sound source is connected and the calculate(
88208
88255
  setTimeout(function(){that.dispatchEvent("ready");}, 50);
88209
88256
  }
88210
88257
  this.dispose = function(context) {
88258
+ // if (lastSource) lastSource.disconnect();
88211
88259
  if (lastSource && analyser) lastSource.disconnect(analyser);
88212
88260
  if (context && audioContext) audioContext.close();
88213
88261
  if (analyser) analyser.disconnect();
@@ -91762,7 +91810,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
91762
91810
  var duo; if (duo = zob(that.loadAssets, arguments, sig)) return duo;
91763
91811
  }
91764
91812
 
91765
- if (!zot(path)) {s
91813
+ if (!zot(path) && path.replace) {
91766
91814
  path = path.replace(/\/$/,"");
91767
91815
  path = path + "/";
91768
91816
  WW.PATH = path;
@@ -92268,7 +92316,7 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
92268
92316
  // now check auto load assets or broken if second
92269
92317
 
92270
92318
  if (WW.PATH!=null) zim.PATH = WW.PATH;
92271
- if (zim.PATH!=null) {
92319
+ if (zim.PATH!=null && zim.PATH.replace) {
92272
92320
  zim.PATH = zim.PATH.replace(/\/$/,"");
92273
92321
  zim.PATH = zim.PATH + "/";
92274
92322
  }