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.
- package/package.json +1 -1
- package/src/zim.js +82 -74
package/package.json
CHANGED
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:
|
|
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
|
-
|
|
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
|
-
//
|
|
95275
|
-
|
|
95276
|
-
|
|
95277
|
-
|
|
95278
|
-
|
|
95279
|
-
|
|
95280
|
-
|
|
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
|
-
//
|
|
95286
|
-
|
|
95287
|
-
|
|
95288
|
-
|
|
95289
|
-
function init(yes) {
|
|
95290
|
-
//
|
|
95291
|
-
|
|
95292
|
-
|
|
95293
|
-
|
|
95294
|
-
|
|
95295
|
-
|
|
95296
|
-
|
|
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
|
-
|
|
95299
|
-
|
|
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
|
-
"
|
|
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
|
|
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
|
-
|
|
95357
|
-
|
|
95358
|
-
|
|
95359
|
-
|
|
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
|
-
|
|
95365
|
-
|
|
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 {
|
|
95369
|
-
|
|
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
|
-
|
|
95379
|
-
const ask = new PermissionAsk(init, permissionType);
|
|
95375
|
+
new PermissionAsk(init, "devicemotion");
|
|
95380
95376
|
function init(yes) {
|
|
95381
|
-
|
|
95382
|
-
|
|
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
|
-
|
|
95387
|
-
|
|
95388
|
-
|
|
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
|
-
|
|
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
|
+
|