zimjs 19.1.3 → 19.1.5

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "19.1.3",
3
+ "version": "19.1.5",
4
4
  "type": "module",
5
5
  "main": "./src/zim.js",
6
6
  "types": "./ts-src/typings/zim",
package/src/zim.js CHANGED
@@ -13370,16 +13370,16 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
13370
13370
  if (p.indexOf(",") != -1) {
13371
13371
  zim.loop(p.split(" "), function (point) {
13372
13372
  var pp = point.split(",");
13373
- points.push([Number(pp[0].trim()), Number(pp[1].trim())]);
13373
+ points.push([Number(pp[0].trim()), Number(pp[1].trim()),0,0,0,0,0,0,"none"]);
13374
13374
  });
13375
13375
  } else {
13376
13376
  var lastP;
13377
13377
  zim.loop(p.split(" "), function (point, i) {
13378
- if ((i+1)%2==0) points.push([lastP, point.trim()]);
13378
+ if ((i+1)%2==0) points.push([Number(lastP), Number(point.trim()),0,0,0,0,0,0,"none"]);
13379
13379
  lastP = point.trim();
13380
13380
  });
13381
13381
  }
13382
- if (type=="polygon") shape = new Blob(f, s, ss, points);
13382
+ if (type=="polygon") shape = new Blob(f, s, ss, points, null, null, null, null, showControls, null, null, null, null, null, null, null, null, null, null, null, null, null, interactive);
13383
13383
  else shape = new zim.Squiggle(s, ss, points, null, null, null, null, showControls, null, null, null, null, null, null, null, null, null, null, null, null, null, interactive);
13384
13384
  } else if (type == "ellipse") {
13385
13385
  shape = new zim.Blob(f, s, ss, ellipse(0, 0, Number(tag.getAttribute("rx")), Number(tag.getAttribute("ry"))), null, null, null, null, showControls, null, null, null, null, null, null, null, null, null, null, null, null, null, interactive);
@@ -28856,6 +28856,13 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28856
28856
 
28857
28857
  if (content) content.center(this);
28858
28858
 
28859
+ var c1 = corner;
28860
+ var c2 = corner;
28861
+ if (Array.isArray(corner)) {
28862
+ c1 = corner[0];
28863
+ c2 = corner[1];
28864
+ }
28865
+
28859
28866
  if (!zot(titleBar)) {
28860
28867
  if (typeof titleBar == "string") titleBar = new zim.Label(titleBar, null, null, titleBarColor);
28861
28868
  var titleBarLabel = that.titleBarLabel = titleBar;
@@ -28865,14 +28872,14 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
28865
28872
  that.titleBar = titleBar = new zim.Container(width, titleBarHeight, null, null, false).centerReg(that).mov(0,-height/2+titleBarHeight/2);
28866
28873
  titleBar.mouseEnabled = false;
28867
28874
  titleBar.mouseChildren = false;
28868
- that.titleBar.backing = new zim.Rectangle(width, titleBarHeight, titleBarBackgroundColor, null, null, [corner*.95,corner*.95, 0,0], null, null, null, false).addTo(titleBar);
28869
- titleBarLabel.center(titleBar).pos({x:Math.max(corner/2, 10), reg:true});
28875
+ that.titleBar.backing = new zim.Rectangle(width, titleBarHeight, titleBarBackgroundColor, null, null, [c1*.95,c2*.95, 0,0], null, null, null, false).addTo(titleBar);
28876
+ titleBarLabel.center(titleBar).pos({x:Math.max(c1/2, 10), reg:true});
28870
28877
  }
28871
28878
 
28872
28879
  if (close) {
28873
28880
  close = that.close = new zim.Shape(-40,-40,80,80,null,false);
28874
28881
  close.graphics.f(closeColor).p("AmJEVIEUkTIkXkWIB4h5IEWEYIETkTIB4B3IkTESIEQERIh4B4IkRkRIkSEVg"); // width about 90 reg in middle
28875
- if (titleBar) close.addTo(that).scaleTo(titleBar, null, 50).mov(width/2-Math.max(corner/2, 10)-close.width/2, -height/2+titleBarHeight/2).expand(40);
28882
+ if (titleBar) close.addTo(that).scaleTo(titleBar, null, 50).mov(width/2-Math.max(c2/2, 10)-close.width/2, -height/2+titleBarHeight/2).expand(40);
28876
28883
  else close.addTo(that).sca(.3).mov(width/2-close.width-3, -height/2+close.height).expand(40);
28877
28884
  close.cur("pointer");
28878
28885
  close.expand();
@@ -33996,7 +34003,7 @@ viewNum - (default 5) how many items to show in the width and height provided
33996
34003
  if no items are provided to start but rather added with addAt() then choose a viewNum that roughly matches how many items will fit in the view
33997
34004
  Note - the items will not be scaled larger by a viewNum setting... only scaled smaller.
33998
34005
  vertical - (default true) set to false to make a horizontal list
33999
- currentSelected - (default false) set to true to show the curret selection as highlighted
34006
+ currentSelected - (default true) set to false to show the current selection as highlighted
34000
34007
  align - (default CENTER) horizontal align
34001
34008
  set to START to align LEFT for ZIM DIR constant is "ltr" or RIGHT when DIR="rtl" - END is the opposite
34002
34009
  valign - (default CENTER) vertical align
@@ -53555,13 +53562,13 @@ RETURNS obj for chaining
53555
53562
  stCheck = true;
53556
53563
  dropListCheck = false;
53557
53564
  stage = obj.stage;
53558
- if (!obj.zmu) obj.zmu = stage.frame.on("mouseupplus", function(e) {
53559
- if (obj.downCheck) {
53560
- // Note - adjusted the mouseupplus event to delay 30ms if triggered on a mousemove
53561
- if (!slide) obj.downCheck = false;
53562
- doUp(e, true); // true for cancel slide
53563
- }
53564
- }, null, null, null, null, mID);
53565
+ // if (!obj.zmu) obj.zmu = stage.frame.on("mouseupplus", function(e) {
53566
+ // if (obj.downCheck) {
53567
+ // // Note - adjusted the mouseupplus event to delay 30ms if triggered on a mousemove
53568
+ // if (!slide) obj.downCheck = false;
53569
+ // doUp(e, true); // true for cancel slide
53570
+ // }
53571
+ // }, null, null, null, null, mID);
53565
53572
 
53566
53573
  obj.dragMouseX = Math.round(e.stageX/zim.scaX)+stage.x;
53567
53574
  obj.dragMouseY = Math.round(e.stageY/zim.scaY)+stage.y;
@@ -54282,10 +54289,10 @@ RETURNS obj for chaining
54282
54289
  obj.off("mousedown", obj.zimDown, null, mID);
54283
54290
  obj.off("pressmove", obj.zimMove, null, mID);
54284
54291
  obj.off("pressup", obj.zimUp, null, mID);
54285
- if (obj.zmu) {
54286
- if (obj.stage) obj.stage.frame.off("mouseupplus", obj.zmu, null, mID);
54287
- else WW.zdf.off("mouseupplus", obj.zmu, null, mID);
54288
- }
54292
+ // if (obj.zmu) {
54293
+ // if (obj.stage) obj.stage.frame.off("mouseupplus", obj.zmu, null, mID);
54294
+ // else WW.zdf.off("mouseupplus", obj.zmu, null, mID);
54295
+ // }
54289
54296
  if (zim.Ticker) {
54290
54297
  if (obj.zimDragSlide) zim.Ticker.remove(obj.zimDragSlide, mID, obj);
54291
54298
  if (obj.zimDragTicker) {
@@ -59906,9 +59913,9 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
59906
59913
 
59907
59914
  target.zimAnimateDragDown = target.on("mousedown", function (e) {
59908
59915
  stage = e.target.stage;
59909
- if (!target.amu) target.amu = stage.frame.on("mouseupplus", function() {
59910
- mouseCheck = false;
59911
- }, null, null, null, null, mID);
59916
+ // if (!target.amu) target.amu = stage.frame.on("mouseupplus", function() {
59917
+ // mouseCheck = false;
59918
+ // }, null, null, null, null, mID);
59912
59919
  stage.mouseMoveOutside = true;
59913
59920
  flipCheck = false; // sometimes picking up target changes its direction - not good
59914
59921
  activeCheck = true;
@@ -61223,7 +61230,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
61223
61230
  target.off("mousedown", target.zimAnimateDragDown, null, mID);
61224
61231
  target.off("pressmove", target.zimAnimateDragPress, null, mID);
61225
61232
  target.off("pressup", target.zimAnimateDragUp, null, mID);
61226
- if (target.amu) stage.frame.off("mouseupplus", target.amu, null, mID);
61233
+ // if (target.amu) stage.frame.off("mouseupplus", target.amu, null, mID);
61227
61234
  if (target.zimDragAnimateTicker) zim.Ticker.remove(target.zimDragAnimateTicker, mID, target);
61228
61235
  }
61229
61236
  if (zot(ids)) {
@@ -75533,7 +75540,7 @@ dispatches a "swipestop" event when swipeup has happened and value has stopped c
75533
75540
  downHandler(e);
75534
75541
  that.moveEvent = container.on("stagemousemove", pressHandler, null, null, null, null, mID);
75535
75542
  that.upEvent = container.on("stagemouseup", doUpStage, null, null, null, null, mID);
75536
- that.upEvent2 = frame.on("mouseupplus", doUpStage, null, null, null, null, mID);
75543
+ // that.upEvent2 = frame.on("mouseupplus", doUpStage, null, null, null, null, mID);
75537
75544
  }, null, null, null, null, mID);
75538
75545
  } else {
75539
75546
  stage = container.stage;
@@ -75541,7 +75548,7 @@ dispatches a "swipestop" event when swipeup has happened and value has stopped c
75541
75548
  that.downEvent = container.on("mousedown", downHandler, null, null, null, null, mID);
75542
75549
  that.moveEvent = container.on("pressmove", pressHandler, null, null, null, null, mID);
75543
75550
  that.upEvent = container.on("pressup", doUpObj, null, null, null, null, mID);
75544
- that.upEvent2 = frame.on("mouseupplus", doUpObj, null, null, null, null, mID);
75551
+ // that.upEvent2 = frame.on("mouseupplus", doUpObj, null, null, null, null, mID);
75545
75552
  }
75546
75553
 
75547
75554
  function doUpStage() {
@@ -75695,13 +75702,13 @@ dispatches a "swipestop" event when swipeup has happened and value has stopped c
75695
75702
  container.off("stagemousedown", that.downEvent, null, mID);
75696
75703
  container.off("stagemousemove", that.moveEvent, null, mID);
75697
75704
  container.off("stagemouseup", that.upEvent, null, mID);
75698
- frame.off("mouseupplus", that.upEvent2, null, mID);
75705
+ // frame.off("mouseupplus", that.upEvent2, null, mID);
75699
75706
  }
75700
75707
  function offMouseEvents() {
75701
75708
  container.off("mousedown", that.downEvent, null, mID);
75702
75709
  container.off("pressmove", that.moveEvent, null, mID);
75703
75710
  container.off("pressup", that.upEvent, null, mID);
75704
- frame.off("mouseupplus", that.upEvent2, null, mID);
75711
+ // frame.off("mouseupplus", that.upEvent2, null, mID);
75705
75712
  }
75706
75713
 
75707
75714
  function disable() {
@@ -75717,7 +75724,7 @@ dispatches a "swipestop" event when swipeup has happened and value has stopped c
75717
75724
  that.downEvent = container.on("mousedown", that.downEvent, null, null, null, null, mID);
75718
75725
  that.moveEvent = container.on("pressmove", that.moveEvent, null, null, null, null, mID);
75719
75726
  that.upEvent = container.on("pressup", that.upEvent, null, null, null, null, mID);
75720
- that.upEvent2 = frame.on("mouseupplus", that.upEvent2, null, null, null, null, mID);
75727
+ // that.upEvent2 = frame.on("mouseupplus", that.upEvent2, null, null, null, null, mID);
75721
75728
  }
75722
75729
  that.immediate(that.target[that.property]);
75723
75730
  that.swiperTicker = zim.Ticker.add(that.swiperTicker, stage, mID, that);
@@ -82505,6 +82512,8 @@ This allows, for instance, matching duplicate letters or colors.
82505
82512
 
82506
82513
  See: https://zimjs.com/cat/scrambler.html
82507
82514
 
82515
+ NOTE: if scaling or moving the scrambler (aside from FIT and FILL scaling) then see beforeUpdate() and afterUpdate()
82516
+
82508
82517
  NOTE: if using Adobe Animate then use the latest ZIM version of CreateJS - see https://zimjs.com/cdn/
82509
82518
 
82510
82519
  NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
@@ -82574,7 +82583,11 @@ solve(time, wait, disable) - solve the tile - so arrange the tile in the start o
82574
82583
  test() - returns true if tiles match starting orientation or keys if keys provided
82575
82584
  testItem(item, index) - test a specific item in the Scrambler to see if correct - index is optional otherwise it will calculate it
82576
82585
  note - there is a "complete" event and complete property so usually there is no need to test an item
82577
- update() - if the Scrambler is moved in its container, call update() to reset drag boundary
82586
+ beforeUpdate() - call this before scaling or moving the scrambler (aside from the FIT or FILL mode scaling) see also afterUpdate()
82587
+ this removes the drag boundary on the tile
82588
+ afterUpdate() - call this after scaling or moving the scrambler (aside from the FIT or FILL mode scaling) see also beforeUpdate()
82589
+ this adds back the drag boundary on the tile
82590
+ update() - DEPRECATED - if the Scrambler is moved in its container, call update() to reset drag boundary
82578
82591
  clone() - makes a copy with properties such as x, y, etc. also copied
82579
82592
  dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
82580
82593
 
@@ -82683,17 +82696,17 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
82683
82696
  // createjs does not do pressup or turn off pressmove when up over iframe
82684
82697
  // so use mouseupplusonly
82685
82698
  // also need normal mouseup with pointer ids to stop multitouch
82686
- if (frame) {
82687
- if (!that.scrmu) that.scrmu = frame.on("mouseupplusonly", function(e) {
82688
- if (that.myDownCheck) {
82689
- that.myDownCheck = false;
82690
- var pp = zim.loop(tile.pointers, function(p,v) {return v;});
82691
- if (!pp) tile.pointers["id0"] = true;
82692
- e = {target:lastTile, pointerID:e.pointerID?pp:-1};
82693
- doUp(e);
82694
- }
82695
- }, null, null, null, null, mID);
82696
- }
82699
+ // if (frame) {
82700
+ // if (!that.scrmu) that.scrmu = frame.on("mouseupplusonly", function(e) {
82701
+ // if (that.myDownCheck) {
82702
+ // that.myDownCheck = false;
82703
+ // var pp = zim.loop(tile.pointers, function(p,v) {return v;});
82704
+ // if (!pp) tile.pointers["id0"] = true;
82705
+ // e = {target:lastTile, pointerID:e.pointerID?pp:-1};
82706
+ // doUp(e);
82707
+ // }
82708
+ // }, null, null, null, null, mID);
82709
+ // }
82697
82710
  if (that.upEvent) tile.off("pressup", that.upEvent, null, mID);
82698
82711
  that.upEvent = tile.on("pressup", function(e) {
82699
82712
  var id = "id"+Math.abs(e.pointerID+1);
@@ -82863,6 +82876,16 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
82863
82876
  return this;
82864
82877
  }
82865
82878
 
82879
+ this.beforeUpdate = function() {
82880
+ tile.noDrag();
82881
+ return this;
82882
+ }
82883
+
82884
+ this.afterUpdate = function() {
82885
+ tile.drag({boundary:tile, singleTouch:true});
82886
+ return this;
82887
+ }
82888
+
82866
82889
  this.starts = [];
82867
82890
  var order = [];
82868
82891
  zim.loop(tile.rows*tile.cols, function (i) {
@@ -83033,7 +83056,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
83033
83056
  });
83034
83057
 
83035
83058
  this.dispose = function(a,b,disposing) {
83036
- if (that.scrmu) frame.off("mouseupplus", that.scrmu, null, mID);
83059
+ // if (that.scrmu) frame.off("mouseupplus", that.scrmu, null, mID);
83037
83060
  tile.removeAllEventListeners(null, mID);
83038
83061
  if (!disposing) {
83039
83062
  that.zimContainer_dispose(true);
@@ -94708,7 +94731,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
94708
94731
  if (zot(bitmap)) bitmap = DS.bitmap!=null?DS.bitmap:true;
94709
94732
  if (zot(splitTypes)) splitTypes = DS.splitTypes!=null?DS.splitTypes:false;
94710
94733
  if (zot(geometric)) geometric = DS.geometric!=null?DS.geometric:true;
94711
- if (zot(showControls)) showControls = DS.showControls!=null?DS.showControls:false;
94734
+ if (zot(showControls)) showControls = DS.showControls!=null?DS.showControls:null;
94712
94735
  if (zot(interactive)) interactive = DS.interactive!=null?DS.interactive:true;
94713
94736
 
94714
94737
  this.zimContainer_constructor(width, height);
@@ -95241,67 +95264,69 @@ DESCRIPTION
95241
95264
  The Frame has a "devicemotion" event to capture device tilt
95242
95265
  and a "deviceorientation" to capture device rotation (like a compass)
95243
95266
 
95244
- Also see the PermissionAsk() class which will handle asking for permission on iOS devices.
95245
-
95246
- NOTE:
95247
- For either event the Frame sensors parameter MUST be set to true
95267
+ SEE: the PermissionAsk() class which will handle asking for permissions on devices.
95248
95268
 
95249
95269
  EXAMPLE
95270
+ // TILT
95250
95271
  // for capturing tilt on device (rotation about an axis)
95251
- // also SEE the PermissionAsk example below
95252
- // also set Frame sensors parameter to true
95253
- // and be on a mobile device
95254
- const label = new Label().center();
95255
- F.on("deviceorientation", e=>{
95256
- label.text = e.rotation.x +","+ e.rotation.y +","+ e.rotation.z;
95257
- S.update();
95272
+ // be on a mobile device
95273
+ new PermissionAsk(yes=>{
95274
+ if (yes) {
95275
+ // all code goes in here
95276
+ const label = new Label().loc(20,20);
95277
+ F.on("deviceorientation", e=>{
95278
+ label.text = "x: " + Math.round(e.rotation.x)
95279
+ +"\ny: " + Math.round(e.rotation.y)
95280
+ +"\nz: " + Math.round(e.rotation.z);
95281
+ S.update();
95282
+ });
95283
+ } else {
95284
+ new Pane("SENSOR not available",yellow).show();
95285
+ }
95258
95286
  });
95259
95287
  END EXAMPLE
95260
95288
 
95261
95289
  EXAMPLE
95262
- // on iOS, the sensors must be allowed first - this example works for all devices
95263
- const label = new Label().center();
95264
- const permissionType = "deviceorientation"; // or "devicemotion"
95265
- const ask = new PermissionAsk(init, permissionType);
95266
- function init(yes) {
95267
- // if the user answers yes to the PermissionAsk
95268
- const errorPane = new Pane("SENSOR not available",yellow);
95269
- if (yes) {
95270
- // use the sensors
95271
- F.on("deviceorientation", e=>{
95272
- label.text = e.rotation.x +","+ e.rotation.y +","+ e.rotation.z;
95273
- S.update();
95290
+ // SHAKE
95291
+ // for capturing shaking motion on device (acceleration about an access)
95292
+ // be on a mobile device
95293
+ new PermissionAsk(init, "devicemotion");
95294
+ function init(yes) {
95295
+ if (yes) { // the user answers yes to the PermissionAsk
95296
+ let id;
95297
+ F.on("devicemotion", e=>{
95298
+ if (
95299
+ Math.abs(e.acceleration.x) > 5 ||
95300
+ Math.abs(e.acceleration.y) > 5 ||
95301
+ Math.abs(e.acceleration.z) > 5
95302
+ ) {
95303
+ if (F.color != red) {
95304
+ F.color = red;
95305
+ S.update();
95306
+ }
95307
+ if (id) id.clear();
95308
+ id = timeout(.2, ()=>{
95309
+ F.color = light;
95310
+ S.update();
95311
+ });
95312
+ }
95274
95313
  });
95275
- S.update();
95276
- } else { // answered no to PermissionAsk dialog
95277
- errorPane.show();
95314
+ } else { // the user answered no to PermissionAsk dialog
95315
+ new Pane("SENSOR not available",yellow).show()
95278
95316
  }
95279
95317
  }
95280
95318
  END EXAMPLE
95281
95319
 
95282
- EXAMPLE
95283
- // for shaking motion - ALSO see the PermissionAsk example above
95284
- // and replace "deviceorientation" with "devicemotion"
95285
- // and replace e.rotation.x, etc. with e.acceleration.x etc.
95286
- // also set Frame sensors parameter to true
95287
- // and be on a mobile device
95288
- const label = new Label().center();
95289
- F.on("devicemotion", e=>{
95290
- label.text = e.acceleration.x +","+ e.acceleration.y +","+ e.acceleration.z;
95291
- S.update();
95292
- });
95293
- END EXAMPLE
95294
-
95295
95320
  EVENTS
95296
- "devicemotion" - for tilt (also set Frame sensors parameter to true)
95297
- fired on moving mobile device - like a tilt or shake - eventObject.acceleration holds x, y and z properties of motion
95298
- "deviceorientation" - for rotation (also set Frame sensors parameter to true)
95321
+ "deviceorientation" - for tilt
95299
95322
  fired as device orientation changes:
95300
95323
  eventObject.rotation.x (beta in HTML specs) holds rotation about the x axis between -180 and 180 (tipped forward or backward)
95301
95324
  eventObject.rotation.y (gamma in HTML specs) holds rotation about the y axis between -90 and 90 (tipped left or right)
95302
95325
  eventObject.rotation.z (alpha in HTML specs) holds rotation about the z axis 0-360 clockwise (relative to orientation when app loads)
95303
95326
  note rotation.z is 360-alpha compared to the HTML 5 specs
95304
95327
  note also that beta, gamma and alpha from the HTML 5 specs are also provided
95328
+ "devicemotion" - for shake
95329
+ fired on moving mobile device - like a shake - eventObject.acceleration holds x, y and z properties of motion
95305
95330
  --*///+83.86
95306
95331
  // Device motion and orientation events are available as Frame events
95307
95332
  //-83.86
@@ -95313,9 +95338,8 @@ PermissionAsk
95313
95338
  zim class - extends a zim.Pane which extends a zim.Container
95314
95339
 
95315
95340
  DESCRIPTION
95316
- A circular confirmation widget to ask the user if they want a permission for iOS.
95341
+ A circular confirmation widget to ask the user if they want a permission on mobile.
95317
95342
  For some iOS permissions, the app needs to be interactive with first before permission can be asked!
95318
- This is for iOS only - if not in iOS then will just pass through the test.
95319
95343
 
95320
95344
  Also adds Frame deviceorientation and devicemotion events for a matching permissionType.
95321
95345
  Pre ZIM 018, this was done with a sensors parameter on the Frame.
@@ -95328,44 +95352,49 @@ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set
95328
95352
  EXAMPLE
95329
95353
  // DEVICE ORIENTATION - gives angle of device in all 3 dimensions
95330
95354
  // Note: this is NOT an orientation event to see if phone is portrait or landscape (see Frame orientation event)
95331
- // new Frame({scaling:FIT, width:1024, height:768, color:white, outerColor:dark, ready:ready, sensors:true});
95332
95355
 
95333
- const permissionType = "deviceorientation";
95334
- const ask = new PermissionAsk(init, permissionType);
95335
- function init(yes) {
95336
- const errorPane = new Pane("SENSOR not available",yellow);
95337
- if (yes) { // the user answers yes to the PermissionAsk
95338
- // use the sensors
95339
- const label = new Label("on mobile").centerReg();
95356
+ new PermissionAsk(yes=>{
95357
+ if (yes) {
95358
+ // all code goes in here
95359
+ const label = new Label().loc(20,20);
95340
95360
  F.on("deviceorientation", e=>{
95341
- // use the sensors
95342
- label.text = label.text = "x: "+decimals(e.rotation.x) +"\ny: "+ decimals(e.rotation.y) +"\nz: "+ decimals(e.rotation.z);
95361
+ label.text = "x: " + Math.round(e.rotation.x)
95362
+ +"\ny: " + Math.round(e.rotation.y)
95363
+ +"\nz: " + Math.round(e.rotation.z);
95343
95364
  S.update();
95344
95365
  });
95345
- } else { // the user answered no to PermissionAsk dialog
95346
- errorPane.show();
95347
- }
95348
- }
95366
+ } else {
95367
+ new Pane("SENSOR not available",yellow).show();
95368
+ }
95369
+ });
95349
95370
  END EXAMPLE
95350
95371
 
95351
95372
  EXAMPLE
95352
95373
  // DEVICE MOTION - gives accelerometer values in all 3 dimensions
95353
- // new Frame({scaling:FIT, width:1024, height:768, color:white, outerColor:dark, ready:ready, sensors:true});
95354
95374
 
95355
- const permissionType = "devicemotion";
95356
- const ask = new PermissionAsk(init, permissionType);
95375
+ new PermissionAsk(init, "devicemotion");
95357
95376
  function init(yes) {
95358
- const errorPane = new Pane("SENSOR not available",yellow);
95359
- if (yes) { // the user answers yes to the PermissionAsk
95360
- // use the sensors
95361
- const label = new Label("on mobile").centerReg();
95377
+ if (yes) { // the user answers yes to the PermissionAsk
95378
+ let id;
95362
95379
  F.on("devicemotion", e=>{
95363
- // use the sensors
95364
- label.text = "x: "+decimals(e.acceleration.x, 3) +"\ny: "+ decimals(e.acceleration.y, 3) +"\nz: "+ decimals(e.acceleration.z, 3);
95365
- S.update();
95380
+ if (
95381
+ Math.abs(e.acceleration.x) > 5 ||
95382
+ Math.abs(e.acceleration.y) > 5 ||
95383
+ Math.abs(e.acceleration.z) > 5
95384
+ ) {
95385
+ if (F.color != red) {
95386
+ F.color = red;
95387
+ S.update();
95388
+ }
95389
+ if (id) id.clear();
95390
+ id = timeout(.2, ()=>{
95391
+ F.color = light;
95392
+ S.update();
95393
+ });
95394
+ }
95366
95395
  });
95367
95396
  } else { // the user answered no to PermissionAsk dialog
95368
- errorPane.show();
95397
+ new Pane("SENSOR not available",yellow).show()
95369
95398
  }
95370
95399
  }
95371
95400
  END EXAMPLE
@@ -95466,7 +95495,8 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
95466
95495
  backgroundColor:zim.faint,
95467
95496
  rollBackgroundColor:color,
95468
95497
  borderColor:color,
95469
- borderWidth:2
95498
+ borderWidth:2,
95499
+ align:CENTER
95470
95500
  });
95471
95501
  var pt = permissionType;
95472
95502
  var okay = false;
@@ -101539,6 +101569,13 @@ Will stretch to fit in dimensions and can choose to flip (default) or not.
101539
101569
  AS OF ZIM 018 - USE ML5 (Machine Learning 5)
101540
101570
  We recommend using ZIM Cam() with the ML5 Library at https://ml5js.org/
101541
101571
  Note: the ML5 library must be imported in a script tag.
101572
+ Note: there are different versions of ML5 with a different format for the code
101573
+ A. More current version is ml5@1 - which takes the latest version 1 code
101574
+ this is used here: https://zimjs.com/018/handtrack.html
101575
+ and needs async and await as in the example above
101576
+ B. Older version is ml5@1.2.1 used in mini site examples
101577
+ here: https://zimjs.com/ml5/hands.html
101578
+ this DOES NOT use async and await
101542
101579
 
101543
101580
  HAND TRACKING WITH ZIM CAM AND ML5
101544
101581
  ZIM Cam has a handTrack(ML5results) method that will replace normal mouse and touch.
@@ -103336,3 +103373,4 @@ export let Style = zim.Style;
103336
103373
  export let assets = zim.assets;
103337
103374
  export let assetIDs = zim.assetIDs;
103338
103375
  export let ZIMON = zim.ZIMON;
103376
+
@@ -2868,24 +2868,6 @@ declare namespace zim {
2868
2868
  readonly orgType: string
2869
2869
  readonly removedItem: DisplayObject
2870
2870
  }
2871
- export class Shuffler extends Container implements zimComponent {
2872
- constructor(config_or_tile?: Tile, spacing?: number, offset?: number, vertical?: boolean, formatObj?: {}, damp?: number, keys?: [any], keyProperty?: string, shuffle?: boolean, time?: number, wait?: number, num?: number, shadowColor?: string, shadowBlur?: number, cache?: boolean, offsetOne?: number, offsetTwo?: number, style?: boolean, group?: string, inherit?: {})
2873
- constructor(config: { tile?: Tile, spacing?: number, offset?: number, vertical?: boolean, formatObj?: {}, damp?: number, keys?: [any], keyProperty?: string, shuffle?: boolean, time?: number, wait?: number, num?: number, shadowColor?: string, shadowBlur?: number, cache?: boolean, offsetOne?: number, offsetTwo?: number, style?: boolean, group?: string, inherit?: {} })
2874
- // ZIM Component Interface
2875
- // dispose():boolean // now added to Container, etc.
2876
- enabled: boolean
2877
- // END ZIM Component Interface
2878
- shuffle(time?: number, wait?: number, num?: number): this
2879
- solve(time?: number, wait?: number, disable?: boolean): this
2880
- test(): this
2881
- update(): this
2882
- testItem(item: DisplayObject, index?: number): this
2883
- format(formatObj: {}): this
2884
- readonly tile: Tile
2885
- readonly complete: boolean
2886
- readonly starts: [number]
2887
- readonly order: [number]
2888
- }
2889
2871
  export class Connectors extends Container implements zimComponent {
2890
2872
  constructor(config_or_width?: number, height?: number, points?: [] | zim.Blob | Squiggle, node?: DisplayObject, line?: Line, linear?: boolean, linearWrap?: boolean, linearOrder?: boolean, num?: number, snapH?: number, snapV?: number, dropType?: string, dropArray?: [number], continuous?: boolean, startIndex?: number, duplicateLines?: boolean, deleteNode?: boolean, dblclick?: boolean, fullMove?: boolean, min?: number, max?: number, boundary?: Boundary | DisplayObject, expand?: number, nodeRollColor?: string, nodeRollBorderColor?: string, nodeSelectedColor?: string, nodeSelectedBorderColor?: string, baseColor?: string, baseBorderColor?: string, baseRollover?: string, rootLock?: boolean, grandChildren?: boolean, dblclickTime?: number, style?: boolean, group?: string, inherit?: {})
2891
2873
  constructor(config: { width?: number, height?: number, points?: [] | zim.Blob | Squiggle, node?: DisplayObject, line?: Line, linear?: boolean, linearWrap?: boolean, linearOrder?: boolean, num?: number, snapH?: number, snapV?: number, dropType?: string, dropArray?: [number], continuous?: boolean, startIndex?: number, duplicateLines?: boolean, deleteNode?: boolean, dblclick?: boolean, fullMove?: boolean, min?: number, max?: number, boundary?: Boundary | DisplayObject, expand?: number, nodeRollColor?: string, nodeRollBorderColor?: string, nodeSelectedColor?: string, nodeSelectedBorderColor?: string, baseColor?: string, baseBorderColor?: string, baseRollover?: string, rootLock?: boolean, grandChildren?: boolean, dblclickTime?: number, style?: boolean, group?: string, inherit?: {} })
@@ -3566,6 +3548,43 @@ declare namespace zim {
3566
3548
  readonly pages: [DisplayObject]
3567
3549
  readonly moving: boolean
3568
3550
  }
3551
+ export class Scrambler extends Container implements zimComponent {
3552
+ constructor(config_or_tile?: Tile, keys?: [any], keyProperty?: string, scramble?: boolean, time?: number, wait?: number, num?: number, shadowColor?: string, shadowBlur?: number, swap?: boolean, swapLock?: boolean, style?: boolean, group?: string, inherit?: {})
3553
+ constructor(config: { tile?: Tile, keys?: [any], keyProperty?: string, scramble?: boolean, time?: number, wait?: number, num?: number, shadowColor?: string, shadowBlur?: number, swap?: boolean, swapLock?: boolean, style?: boolean, group?: string, inherit?: {} })
3554
+ // ZIM Component Interface
3555
+ // dispose():boolean // now added to Container, etc.
3556
+ enabled: boolean
3557
+ // END ZIM Component Interface
3558
+ scramble(time?: number, wait?: number, num?: number): this
3559
+ solve(time?: number, wait?: number, disable?: boolean): this
3560
+ test(): this
3561
+ testItem(item: DisplayObject, index?: number): this
3562
+ beforeUpdate(): this
3563
+ afterUpdate(): this
3564
+ update(): this
3565
+ readonly tile: Tile
3566
+ readonly complete: boolean
3567
+ readonly starts: [number]
3568
+ order: [number]
3569
+ }
3570
+ export class Shuffler extends Container implements zimComponent {
3571
+ constructor(config_or_tile?: Tile, spacing?: number, offset?: number, vertical?: boolean, formatObj?: {}, damp?: number, keys?: [any], keyProperty?: string, shuffle?: boolean, time?: number, wait?: number, num?: number, shadowColor?: string, shadowBlur?: number, cache?: boolean, offsetOne?: number, offsetTwo?: number, style?: boolean, group?: string, inherit?: {})
3572
+ constructor(config: { tile?: Tile, spacing?: number, offset?: number, vertical?: boolean, formatObj?: {}, damp?: number, keys?: [any], keyProperty?: string, shuffle?: boolean, time?: number, wait?: number, num?: number, shadowColor?: string, shadowBlur?: number, cache?: boolean, offsetOne?: number, offsetTwo?: number, style?: boolean, group?: string, inherit?: {} })
3573
+ // ZIM Component Interface
3574
+ // dispose():boolean // now added to Container, etc.
3575
+ enabled: boolean
3576
+ // END ZIM Component Interface
3577
+ shuffle(time?: number, wait?: number, num?: number): this
3578
+ solve(time?: number, wait?: number, disable?: boolean): this
3579
+ test(): this
3580
+ update(): this
3581
+ testItem(item: DisplayObject, index?: number): this
3582
+ format(formatObj: {}): this
3583
+ readonly tile: Tile
3584
+ readonly complete: boolean
3585
+ readonly starts: [number]
3586
+ order: [number]
3587
+ }
3569
3588
  export class Scroller extends createjs.EventDispatcher {
3570
3589
  constructor(config_or_backing: DisplayObject, speed?: number, direction?: number, horizontal?: boolean, gapFix?: number, stage?: Stage, container?: Stage | DisplayObject)
3571
3590
  constructor(config: { backing: DisplayObject, speed?: number, direction?: number, horizontal?: boolean, gapFix?: number, stage?: Stage, container?: Stage | DisplayObject })