zimjs 19.1.4 → 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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/zim.js +82 -74
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "19.1.4",
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);
@@ -94731,7 +94731,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
94731
94731
  if (zot(bitmap)) bitmap = DS.bitmap!=null?DS.bitmap:true;
94732
94732
  if (zot(splitTypes)) splitTypes = DS.splitTypes!=null?DS.splitTypes:false;
94733
94733
  if (zot(geometric)) geometric = DS.geometric!=null?DS.geometric:true;
94734
- if (zot(showControls)) showControls = DS.showControls!=null?DS.showControls:false;
94734
+ if (zot(showControls)) showControls = DS.showControls!=null?DS.showControls:null;
94735
94735
  if (zot(interactive)) interactive = DS.interactive!=null?DS.interactive:true;
94736
94736
 
94737
94737
  this.zimContainer_constructor(width, height);
@@ -95264,67 +95264,69 @@ DESCRIPTION
95264
95264
  The Frame has a "devicemotion" event to capture device tilt
95265
95265
  and a "deviceorientation" to capture device rotation (like a compass)
95266
95266
 
95267
- Also see the PermissionAsk() class which will handle asking for permission on iOS devices.
95268
-
95269
- NOTE:
95270
- 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.
95271
95268
 
95272
95269
  EXAMPLE
95270
+ // TILT
95273
95271
  // for capturing tilt on device (rotation about an axis)
95274
- // also SEE the PermissionAsk example below
95275
- // also set Frame sensors parameter to true
95276
- // and be on a mobile device
95277
- const label = new Label().center();
95278
- F.on("deviceorientation", e=>{
95279
- label.text = e.rotation.x +","+ e.rotation.y +","+ e.rotation.z;
95280
- 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
+ }
95281
95286
  });
95282
95287
  END EXAMPLE
95283
95288
 
95284
95289
  EXAMPLE
95285
- // on iOS, the sensors must be allowed first - this example works for all devices
95286
- const label = new Label().center();
95287
- const permissionType = "deviceorientation"; // or "devicemotion"
95288
- const ask = new PermissionAsk(init, permissionType);
95289
- function init(yes) {
95290
- // if the user answers yes to the PermissionAsk
95291
- const errorPane = new Pane("SENSOR not available",yellow);
95292
- if (yes) {
95293
- // use the sensors
95294
- F.on("deviceorientation", e=>{
95295
- label.text = e.rotation.x +","+ e.rotation.y +","+ e.rotation.z;
95296
- 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
+ }
95297
95313
  });
95298
- S.update();
95299
- } else { // answered no to PermissionAsk dialog
95300
- errorPane.show();
95314
+ } else { // the user answered no to PermissionAsk dialog
95315
+ new Pane("SENSOR not available",yellow).show()
95301
95316
  }
95302
95317
  }
95303
95318
  END EXAMPLE
95304
95319
 
95305
- EXAMPLE
95306
- // for shaking motion - ALSO see the PermissionAsk example above
95307
- // and replace "deviceorientation" with "devicemotion"
95308
- // and replace e.rotation.x, etc. with e.acceleration.x etc.
95309
- // also set Frame sensors parameter to true
95310
- // and be on a mobile device
95311
- const label = new Label().center();
95312
- F.on("devicemotion", e=>{
95313
- label.text = e.acceleration.x +","+ e.acceleration.y +","+ e.acceleration.z;
95314
- S.update();
95315
- });
95316
- END EXAMPLE
95317
-
95318
95320
  EVENTS
95319
- "devicemotion" - for tilt (also set Frame sensors parameter to true)
95320
- fired on moving mobile device - like a tilt or shake - eventObject.acceleration holds x, y and z properties of motion
95321
- "deviceorientation" - for rotation (also set Frame sensors parameter to true)
95321
+ "deviceorientation" - for tilt
95322
95322
  fired as device orientation changes:
95323
95323
  eventObject.rotation.x (beta in HTML specs) holds rotation about the x axis between -180 and 180 (tipped forward or backward)
95324
95324
  eventObject.rotation.y (gamma in HTML specs) holds rotation about the y axis between -90 and 90 (tipped left or right)
95325
95325
  eventObject.rotation.z (alpha in HTML specs) holds rotation about the z axis 0-360 clockwise (relative to orientation when app loads)
95326
95326
  note rotation.z is 360-alpha compared to the HTML 5 specs
95327
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
95328
95330
  --*///+83.86
95329
95331
  // Device motion and orientation events are available as Frame events
95330
95332
  //-83.86
@@ -95336,9 +95338,8 @@ PermissionAsk
95336
95338
  zim class - extends a zim.Pane which extends a zim.Container
95337
95339
 
95338
95340
  DESCRIPTION
95339
- 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.
95340
95342
  For some iOS permissions, the app needs to be interactive with first before permission can be asked!
95341
- This is for iOS only - if not in iOS then will just pass through the test.
95342
95343
 
95343
95344
  Also adds Frame deviceorientation and devicemotion events for a matching permissionType.
95344
95345
  Pre ZIM 018, this was done with a sensors parameter on the Frame.
@@ -95351,44 +95352,49 @@ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set
95351
95352
  EXAMPLE
95352
95353
  // DEVICE ORIENTATION - gives angle of device in all 3 dimensions
95353
95354
  // Note: this is NOT an orientation event to see if phone is portrait or landscape (see Frame orientation event)
95354
- // new Frame({scaling:FIT, width:1024, height:768, color:white, outerColor:dark, ready:ready, sensors:true});
95355
95355
 
95356
- const permissionType = "deviceorientation";
95357
- const ask = new PermissionAsk(init, permissionType);
95358
- function init(yes) {
95359
- const errorPane = new Pane("SENSOR not available",yellow);
95360
- if (yes) { // the user answers yes to the PermissionAsk
95361
- // use the sensors
95362
- 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);
95363
95360
  F.on("deviceorientation", e=>{
95364
- // use the sensors
95365
- 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);
95366
95364
  S.update();
95367
95365
  });
95368
- } else { // the user answered no to PermissionAsk dialog
95369
- errorPane.show();
95370
- }
95371
- }
95366
+ } else {
95367
+ new Pane("SENSOR not available",yellow).show();
95368
+ }
95369
+ });
95372
95370
  END EXAMPLE
95373
95371
 
95374
95372
  EXAMPLE
95375
95373
  // DEVICE MOTION - gives accelerometer values in all 3 dimensions
95376
- // new Frame({scaling:FIT, width:1024, height:768, color:white, outerColor:dark, ready:ready, sensors:true});
95377
95374
 
95378
- const permissionType = "devicemotion";
95379
- const ask = new PermissionAsk(init, permissionType);
95375
+ new PermissionAsk(init, "devicemotion");
95380
95376
  function init(yes) {
95381
- const errorPane = new Pane("SENSOR not available",yellow);
95382
- if (yes) { // the user answers yes to the PermissionAsk
95383
- // use the sensors
95384
- const label = new Label("on mobile").centerReg();
95377
+ if (yes) { // the user answers yes to the PermissionAsk
95378
+ let id;
95385
95379
  F.on("devicemotion", e=>{
95386
- // use the sensors
95387
- label.text = "x: "+decimals(e.acceleration.x, 3) +"\ny: "+ decimals(e.acceleration.y, 3) +"\nz: "+ decimals(e.acceleration.z, 3);
95388
- 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
+ }
95389
95395
  });
95390
95396
  } else { // the user answered no to PermissionAsk dialog
95391
- errorPane.show();
95397
+ new Pane("SENSOR not available",yellow).show()
95392
95398
  }
95393
95399
  }
95394
95400
  END EXAMPLE
@@ -95489,7 +95495,8 @@ alpha, cursor, shadow, name, mouseChildren, mouseEnabled, parent, numChildren, e
95489
95495
  backgroundColor:zim.faint,
95490
95496
  rollBackgroundColor:color,
95491
95497
  borderColor:color,
95492
- borderWidth:2
95498
+ borderWidth:2,
95499
+ align:CENTER
95493
95500
  });
95494
95501
  var pt = permissionType;
95495
95502
  var okay = false;
@@ -103366,3 +103373,4 @@ export let Style = zim.Style;
103366
103373
  export let assets = zim.assets;
103367
103374
  export let assetIDs = zim.assetIDs;
103368
103375
  export let ZIMON = zim.ZIMON;
103376
+