zimjs 16.2.5 → 16.2.7
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 +205 -170
- package/ts-src/typings/zim/index.d.ts +4 -0
package/package.json
CHANGED
package/src/zim.js
CHANGED
|
@@ -3458,8 +3458,8 @@ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set
|
|
|
3458
3458
|
EXAMPLE
|
|
3459
3459
|
const blob = new Blob().center();
|
|
3460
3460
|
const points = blob.segmentPoints;
|
|
3461
|
-
S.on("stagemousedown",
|
|
3462
|
-
const point = blob.globalToLocal(
|
|
3461
|
+
S.on("stagemousedown", ()=>{
|
|
3462
|
+
const point = blob.globalToLocal(F.mouseX, F.mouseY)
|
|
3463
3463
|
zog(closestPointAlongCurve({x:point.x, y:point.y}, points))
|
|
3464
3464
|
// gives index of point on curve before mouse location
|
|
3465
3465
|
});
|
|
@@ -3489,14 +3489,21 @@ RETURNS the index of the closest point in segmentPoints before the given point
|
|
|
3489
3489
|
var index = 0;
|
|
3490
3490
|
var secondaryIndex = 0;
|
|
3491
3491
|
if (zot(num)) num = 10;
|
|
3492
|
+
var totalD = 0;
|
|
3493
|
+
var totals = [];
|
|
3494
|
+
var lastDist=0;
|
|
3492
3495
|
zim.loop(segmentPoints, function(points, i) {
|
|
3493
3496
|
// add num more points to estimate closest
|
|
3497
|
+
var dist = zim.distanceAlongCurve(points);
|
|
3498
|
+
totalD += dist;
|
|
3494
3499
|
var cubic = new zim.Bezier(points[0],points[1],points[2],points[3]);
|
|
3495
3500
|
zim.loop(num, function (j, total) {
|
|
3496
3501
|
// var d = zim.dist(point, zim.pointAlongCurve(segmentPoints(that.points[i], that.points[i<t-1?i+1:0]), j/10));
|
|
3497
3502
|
// var testPoint = zim.pointAlongCurve(points, j/total);
|
|
3498
3503
|
// var d = zim.dist(point, testPoint);
|
|
3499
|
-
|
|
3504
|
+
totals.push(lastDist+dist*j/total);
|
|
3505
|
+
// if (even) var testPoint = {x:cubic.mx(j/total), y:cubic.my(j/total)};
|
|
3506
|
+
var testPoint = {x:cubic.x(j/total), y:cubic.y(j/total)};
|
|
3500
3507
|
var d = zim.dist(point, testPoint);
|
|
3501
3508
|
if (d < closest) {
|
|
3502
3509
|
closest = d;
|
|
@@ -3505,9 +3512,11 @@ RETURNS the index of the closest point in segmentPoints before the given point
|
|
|
3505
3512
|
secondaryIndex = j;
|
|
3506
3513
|
}
|
|
3507
3514
|
});
|
|
3515
|
+
lastDist = totalD;
|
|
3508
3516
|
});
|
|
3509
3517
|
if (percentage) {
|
|
3510
|
-
return (index*num+secondaryIndex)/
|
|
3518
|
+
return (totals[index*num+secondaryIndex]||0)/totalD*100;
|
|
3519
|
+
// return (index*num+secondaryIndex)/(segmentPoints.length*num)*100;
|
|
3511
3520
|
} else if (interpolate) {
|
|
3512
3521
|
return closestTestPoint;
|
|
3513
3522
|
}
|
|
@@ -6558,11 +6567,11 @@ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set
|
|
|
6558
6567
|
|
|
6559
6568
|
EXAMPLE
|
|
6560
6569
|
const assets = "flecks.jpg";
|
|
6561
|
-
const path = "assets/";
|
|
6570
|
+
const path = "https://zimjs.org/assets/";
|
|
6562
6571
|
new Frame(scaling, width, height, color, outerColor, ready, assets, path);
|
|
6563
6572
|
function ready() {
|
|
6564
6573
|
new Rectangle(W, H, new BitmapColor("flecks.jpg")).addTo();
|
|
6565
|
-
// or use
|
|
6574
|
+
// or use new Pic("flecks.jpg") instead of string "flecks.jpg" - but ZIM will figure it out
|
|
6566
6575
|
}
|
|
6567
6576
|
END EXAMPLE
|
|
6568
6577
|
|
|
@@ -13788,7 +13797,8 @@ clone(exact) - makes a copy of the shape
|
|
|
13788
13797
|
For instance, if the object's color is [blue, green]
|
|
13789
13798
|
then its clone might be blue or green - which could be different than the original
|
|
13790
13799
|
If exact is set to true then the clone will be the color of the original object
|
|
13791
|
-
|
|
13800
|
+
Warning: clone does not clone any content added to a shape - use a Container for that - see cloneAll()
|
|
13801
|
+
cloneAll(exact, style, group, inherit) - copies shape and any custom content in shape - experimental
|
|
13792
13802
|
exact (default false) in theory will copy ZIM VEE values as they are in the original
|
|
13793
13803
|
see main class for style, group, inherit parameters
|
|
13794
13804
|
dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
|
|
@@ -14062,7 +14072,8 @@ clone(exact) - makes a copy of the shape
|
|
|
14062
14072
|
For instance, if the object's color is [blue, green]
|
|
14063
14073
|
then its clone might be blue or green - which could be different than the original
|
|
14064
14074
|
If exact is set to true then the clone will be the color of the original object
|
|
14065
|
-
|
|
14075
|
+
Warning: clone does not clone any content added to a shape - use a Container for that - see cloneAll()
|
|
14076
|
+
cloneAll(exact style, group, inherit) - copies shape and any custom content in shape - experimental
|
|
14066
14077
|
exact (default false) in theory will copy ZIM VEE values as they are in the original
|
|
14067
14078
|
see main class for style, group, inherit parameters
|
|
14068
14079
|
dispose() - removes from parent, removes event listeners - must still set outside references to null for garbage collection
|
|
@@ -14305,12 +14316,13 @@ if one color is used, the current color is used and color1 is the second color i
|
|
|
14305
14316
|
cache(see Container docs for parameter description) - overrides CreateJS cache() and returns object for chaining
|
|
14306
14317
|
Leave parameters blank to cache bounds of shape (plus outer edge of border if borderWidth > 0)
|
|
14307
14318
|
hasProp(property as String) - returns true if property exists on object else returns false
|
|
14308
|
-
clone() - makes a copy of the shape
|
|
14309
|
-
exact (default false) ZIM VEE (Pick) values are active in clones unless exact is set to true
|
|
14319
|
+
clone(exact) - makes a copy of the shape
|
|
14320
|
+
exact (default false) ZIM VEE (Pick) values are active in clones unless exact is set to true
|
|
14310
14321
|
For instance, if the object's color is [blue, green]
|
|
14311
14322
|
then its clone might be blue or green - which could be different than the original
|
|
14312
14323
|
If exact is set to true then the clone will be the color of the original object
|
|
14313
|
-
|
|
14324
|
+
Warning: clone does not clone any content added to a shape - use a Container for that - see cloneAll()
|
|
14325
|
+
cloneAll(exact style, group, inherit) - copies shape and any custom content in shape - experimental
|
|
14314
14326
|
exact (default false) in theory will copy ZIM VEE values as they are in the original
|
|
14315
14327
|
see main class for style, group, inherit parameters
|
|
14316
14328
|
exact (default false) in theory will copy ZIM VEE values as they are in the original
|
|
@@ -21913,7 +21925,7 @@ zim.LabelOnPath = function(label, path, percentAngle, percents, showPath, allowT
|
|
|
21913
21925
|
return that;
|
|
21914
21926
|
};
|
|
21915
21927
|
|
|
21916
|
-
that.toggle(true);
|
|
21928
|
+
if (showPath) that.toggle(true);
|
|
21917
21929
|
|
|
21918
21930
|
if (style!==false) zim.styleTransforms(this, DS);
|
|
21919
21931
|
this.clone = function() {
|
|
@@ -36134,6 +36146,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
36134
36146
|
this.type = "NumPad";
|
|
36135
36147
|
|
|
36136
36148
|
var that = this;
|
|
36149
|
+
|
|
36137
36150
|
|
|
36138
36151
|
function ms(letter, color) {
|
|
36139
36152
|
if (zot(color)) color = mist;
|
|
@@ -36143,7 +36156,12 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
36143
36156
|
ms("C",zim.red.darken(.1)),ms(new zim.Label({text:"␣", size:90, shiftV:-24}),zim.yellow.darken(.1)),ms(new zim.Label({text:"/",size:48,bold:true,shiftV:3})),ms(new zim.Label({text:"*", size:65, shiftV:18})),
|
|
36144
36157
|
1,2,3,ms(new zim.Label({text:"-",size:60,shiftV:-3})),4,5,6,ms(new zim.Label({text:"+",size:55,shiftV:3})),
|
|
36145
36158
|
7,8,9,ms(new zim.Label({text:"⌫",size:M=="ios"?60:35}), zim.red.darken(.1)),
|
|
36146
|
-
ms(new zim.Label({text:",",size:70,shiftV:-3})),ms(new Label({text:".",size:70,shiftV:-3})),0,ms(new zim.Label({text:"⏎", size:M=="ios"?40:50, shiftV:5}), zim.green.darken(.1))]
|
|
36159
|
+
ms(new zim.Label({text:",",size:70,shiftV:-3})),ms(new Label({text:".",size:70,shiftV:-3})),0,ms(new zim.Label({text:"⏎", size:M=="ios"?40:50, shiftV:5}), zim.green.darken(.1))];
|
|
36160
|
+
|
|
36161
|
+
|
|
36162
|
+
function isRTL(){
|
|
36163
|
+
return getComputedStyle(zdf.canvas).direction == "rtl";
|
|
36164
|
+
};
|
|
36147
36165
|
if (advanced=="simple") {
|
|
36148
36166
|
padArray.splice(0,4);
|
|
36149
36167
|
padArray.splice(3,1);
|
|
@@ -36155,8 +36173,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
36155
36173
|
} else if (advanced) {
|
|
36156
36174
|
padArray.splice(2,0,ms("%", yellow.darken(.1)));
|
|
36157
36175
|
padArray.splice(4,0,ms(new zim.Label({text:"^",size:47,shiftV:10}), yellow.darken(.1)));
|
|
36158
|
-
padArray.splice(4,0,ms(")", yellow.darken(.1)));
|
|
36159
|
-
padArray.splice(4,0,ms("(", yellow.darken(.1)));
|
|
36176
|
+
padArray.splice(4,0,ms(isRTL()?"(":")", yellow.darken(.1)));
|
|
36177
|
+
padArray.splice(4,0,ms(isRTL()?")":"(", yellow.darken(.1)));
|
|
36160
36178
|
}
|
|
36161
36179
|
that.pad = new zim.Pad({
|
|
36162
36180
|
width:advanced=="simple"?290:380,
|
|
@@ -39266,6 +39284,7 @@ Dispatches a "keydown" event with an event object having a letter property
|
|
|
39266
39284
|
keyboard.on("keydown", function(e) {zog(e.letter);}); // logs letter pressed or "del" for delete
|
|
39267
39285
|
Dispatches a "special" event if the special parameter is used and the special key is pressed
|
|
39268
39286
|
Dispatches a "close" event when close keyboard icon at bottom right is pressed
|
|
39287
|
+
Dispatches "numpadopen" and "numpadclose" events when the NumPad is opened or closed
|
|
39269
39288
|
|
|
39270
39289
|
ALSO: see the CreateJS Easel Docs for Container events such as:
|
|
39271
39290
|
added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmove, pressup, removed, rollout, rollover
|
|
@@ -40042,15 +40061,18 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
40042
40061
|
that.toggled = false;
|
|
40043
40062
|
removeCursorShiftMenu();
|
|
40044
40063
|
}
|
|
40064
|
+
that.dispatchEvent("numpadclose");
|
|
40045
40065
|
});
|
|
40046
40066
|
}
|
|
40047
40067
|
|
|
40048
40068
|
numPadKey.removeChildAt(2);
|
|
40049
40069
|
if (that.numPad.parent || status === false) {
|
|
40050
40070
|
that.numPad.removeFrom();
|
|
40071
|
+
that.dispatchEvent("numpadclose");
|
|
40051
40072
|
showNumPadIcon.clone().scaleTo(numPadKey, 60, 60).centerReg(numPadKey,2);
|
|
40052
40073
|
} else if (!that.numPad.parent || status === true) {
|
|
40053
40074
|
that.numPad.addTo();
|
|
40075
|
+
that.dispatchEvent("numpadopen");
|
|
40054
40076
|
hideNumPadIcon.clone().scaleTo(numPadKey, 60, 60).centerReg(numPadKey,2);
|
|
40055
40077
|
}
|
|
40056
40078
|
currentKeyboard.updateCache();
|
|
@@ -50399,9 +50421,8 @@ RETURNS obj for chaining
|
|
|
50399
50421
|
if (!redoChache) obj.updateCache();
|
|
50400
50422
|
else obj.cache();
|
|
50401
50423
|
}
|
|
50402
|
-
if (obj.alphaMask) {
|
|
50403
|
-
|
|
50404
|
-
obj.alphaMask.updateCache();
|
|
50424
|
+
if (obj.effects && obj.effects.alpha && obj.effects.alpha.alphaMask.updateCache) {
|
|
50425
|
+
obj.effects.alpha.alphaMask.updateCache();
|
|
50405
50426
|
}
|
|
50406
50427
|
return obj;
|
|
50407
50428
|
};//-33.163
|
|
@@ -57323,19 +57344,18 @@ There are settings that can adjust when the Ticker updates so see Usage notes be
|
|
|
57323
57344
|
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
57324
57345
|
|
|
57325
57346
|
EXAMPLE
|
|
57326
|
-
const circle = new Circle(50, red);
|
|
57327
|
-
circle.center();
|
|
57347
|
+
const circle = new Circle(50, red).center();
|
|
57328
57348
|
Ticker.add(()=>{
|
|
57329
57349
|
circle.x++;
|
|
57330
|
-
}
|
|
57350
|
+
}); // can also pass in a specific stage
|
|
57331
57351
|
|
|
57332
57352
|
// to be able to remove the function:
|
|
57333
|
-
Ticker.add(tryMe
|
|
57353
|
+
Ticker.add(tryMe);
|
|
57334
57354
|
function tryMe() {circle.x++;}
|
|
57335
57355
|
Ticker.remove(tryMe);
|
|
57336
57356
|
|
|
57337
57357
|
// OR with function literal, use the return value
|
|
57338
|
-
var tickerFunction = Ticker.add(()=>{circle.x++;}
|
|
57358
|
+
var tickerFunction = Ticker.add(()=>{circle.x++;});
|
|
57339
57359
|
Ticker.remove(tickerFunction);
|
|
57340
57360
|
|
|
57341
57361
|
// Check to see if a function is in the Ticker for that stage:
|
|
@@ -57349,6 +57369,7 @@ however, OPTIMIZE can be overridden as follows (or with the always() method):
|
|
|
57349
57369
|
METHODS (static)
|
|
57350
57370
|
** As of ZIM 5.1.0, stage is optional and will default to the stage of first Frame object made
|
|
57351
57371
|
** WARNING - if you are in a second Frame you should pass stage as a parameter so it does not point to the first Frame's stage
|
|
57372
|
+
** NOTE - if no stage is provided, the Ticker will update the stage of the zdf - ZIM default frame (usually the first Frame made)
|
|
57352
57373
|
Ticker.always(stage) - overrides OPTIMIZE and always runs an update for the stage even with no function in queue
|
|
57353
57374
|
Ticker.alwaysOff(stage) - stops an always Ticker for a stage
|
|
57354
57375
|
Ticker.add(function, stage) - adds the function to the Ticker queue for a given stage and returns the function that was added
|
|
@@ -57726,7 +57747,7 @@ const pages = new Pages({
|
|
|
57726
57747
|
}).addTo();
|
|
57727
57748
|
|
|
57728
57749
|
// handle any events inserted into the swipe arrays
|
|
57729
|
-
pages.on("info",
|
|
57750
|
+
pages.on("info", ()=>{zog("info requested")});
|
|
57730
57751
|
|
|
57731
57752
|
// handle any custom requirements when arriving at a page
|
|
57732
57753
|
// the event gives you the page object
|
|
@@ -57734,13 +57755,13 @@ pages.on("info", function(){zog("info requested")});
|
|
|
57734
57755
|
home.name = "home";
|
|
57735
57756
|
hide.name = "hide";
|
|
57736
57757
|
find.name = "find";
|
|
57737
|
-
pages.on("page",
|
|
57758
|
+
pages.on("page", ()=>{
|
|
57738
57759
|
zog(pages.page.name); // now we know which page we are on
|
|
57739
57760
|
})
|
|
57740
57761
|
|
|
57741
57762
|
// you can manually go to pages as well
|
|
57742
57763
|
// we will make a little triangle to click:
|
|
57743
|
-
|
|
57764
|
+
const back = new Triangle({color:red});
|
|
57744
57765
|
back.center(find); // add triangle to find page
|
|
57745
57766
|
// not really supposed to add things to zim shapes
|
|
57746
57767
|
// they default to mouseChildren false
|
|
@@ -57748,8 +57769,7 @@ back.center(find); // add triangle to find page
|
|
|
57748
57769
|
// so we have to set the mouseChildren of find to true
|
|
57749
57770
|
find.mouseChildren = true;
|
|
57750
57771
|
back.cur();
|
|
57751
|
-
back.on("click",
|
|
57752
|
-
S.update();
|
|
57772
|
+
back.on("click", ()=>{pages.go(home, UP)});
|
|
57753
57773
|
END EXAMPLE
|
|
57754
57774
|
|
|
57755
57775
|
PARAMETERS
|
|
@@ -58689,6 +58709,125 @@ Additional "mousedown", "click" or other button events can be added if desired
|
|
|
58689
58709
|
zim.extend(zim.Arrow, zim.Button, "clone", "zimButton", false);
|
|
58690
58710
|
//-71.2
|
|
58691
58711
|
|
|
58712
|
+
|
|
58713
|
+
/*--
|
|
58714
|
+
zim.HotSpot = function(obj, x, y, width, height, call, callOver, callOut, local, talk)
|
|
58715
|
+
|
|
58716
|
+
HotSpot
|
|
58717
|
+
zim class - extends a zim.Container which extends a createjs.Container
|
|
58718
|
+
|
|
58719
|
+
DESCRIPTION
|
|
58720
|
+
HotSpot adds an invisible button to a container object (often think of this as the page).
|
|
58721
|
+
If you want multiple spots it is more efficient to use the HotSpots class above
|
|
58722
|
+
which manages multiple HotSpot objects (otherwise you end up with multiple event functions).
|
|
58723
|
+
The spot is a pixel rect with an alpha of .01 and then uses a hitArea of a backing shape.
|
|
58724
|
+
The spot will get a cursor of "pointer".
|
|
58725
|
+
|
|
58726
|
+
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
58727
|
+
|
|
58728
|
+
EXAMPLE
|
|
58729
|
+
const hs = new HotSpot(S, 100, 100, 50, 50, myFunction);
|
|
58730
|
+
function myFunction() {
|
|
58731
|
+
zog("activation!");
|
|
58732
|
+
}
|
|
58733
|
+
// hs.show(); // uncomment this to see rectangle hotSpot
|
|
58734
|
+
END EXAMPLE
|
|
58735
|
+
|
|
58736
|
+
PARAMETERS supports DUO - parameters or single object with properties below
|
|
58737
|
+
holder - container object in which to place the hotspot (stage for instance)
|
|
58738
|
+
x, y, width and height - of the rectangle for the hotspot
|
|
58739
|
+
call - the function to call when the spot is pressed
|
|
58740
|
+
local - (default true) hotSpot rect is based on local coordinates of the container
|
|
58741
|
+
use when the element scale independently from the stage
|
|
58742
|
+
if set to false then you pass in global coordinates and hotSpot will convert them
|
|
58743
|
+
talk - (default "hotspot") text for ZIM Accessibility screen reader
|
|
58744
|
+
|
|
58745
|
+
METHODS
|
|
58746
|
+
show() - helps when creating the spot to see where it is
|
|
58747
|
+
hide() - hides the hotspot
|
|
58748
|
+
dispose() - removes the listener and the spot
|
|
58749
|
+
|
|
58750
|
+
PROPERTIES
|
|
58751
|
+
type - holds the class name as a String
|
|
58752
|
+
spot - the actual hotSpot object that gets added to the container can be accessed with the spot property
|
|
58753
|
+
eg. hs.spot
|
|
58754
|
+
|
|
58755
|
+
ACTIONEVENT
|
|
58756
|
+
This component is affected by the general ACTIONEVENT setting
|
|
58757
|
+
The default is "mousedown" - if set to something else the component will act on click (press)
|
|
58758
|
+
--*///+73
|
|
58759
|
+
zim.HotSpot = function(obj, x, y, width, height, call, callOver, callOut, local, talk) {
|
|
58760
|
+
var sig = "obj, x, y, width, height, call, callOver, callOut, local, talk";
|
|
58761
|
+
var duo; if (duo = zob(zim.HotSpot, arguments, sig, this)) return duo;
|
|
58762
|
+
z_d("73");
|
|
58763
|
+
this.zimContainer_constructor(null,null,null,null,false);
|
|
58764
|
+
this.type = "HotSpot";
|
|
58765
|
+
|
|
58766
|
+
if (zot(obj) || !obj.addChild) {zogy("zim controls - HotSpot():\nPlease pass in container object for obj"); return;}
|
|
58767
|
+
if (obj instanceof createjs.Container == false) {zogy("zim controls - HotSpot():\nObjects passed in should be Containers"); return;}
|
|
58768
|
+
if (zot(x) || zot(y) || zot(width) || zot(height)) {zogy("zim controls - HotSpot():\nPlease pass in x, y, width, height"); return;}
|
|
58769
|
+
if (zot(local)) local = true;
|
|
58770
|
+
var eventType = (!zns?WW.ACTIONEVENT=="mousedown":zim.ACTIONEVENT=="mousedown")?"mousedown":"click";
|
|
58771
|
+
|
|
58772
|
+
var w = width; var h = height;
|
|
58773
|
+
var point,newW,newH;
|
|
58774
|
+
if (!local) {
|
|
58775
|
+
point = obj.globalToLocal(x,y);
|
|
58776
|
+
var point2 = obj.globalToLocal(x+w,y+h);
|
|
58777
|
+
newW = point2.x-point.x;
|
|
58778
|
+
newH = point2.y-point.y;
|
|
58779
|
+
} else {
|
|
58780
|
+
point = new zim.Point(x,y);
|
|
58781
|
+
newW = width;
|
|
58782
|
+
newH = height;
|
|
58783
|
+
}
|
|
58784
|
+
var but = new zim.Shape(width, height);
|
|
58785
|
+
but.talk = zot(talk)?"HotSpot":talk;
|
|
58786
|
+
but.alpha = 0;
|
|
58787
|
+
but.graphics.f("black").dr(0,0,newW,newH);
|
|
58788
|
+
but.x = point.x;
|
|
58789
|
+
but.y = point.y;
|
|
58790
|
+
but.cur("pointer");
|
|
58791
|
+
but.expand(0);
|
|
58792
|
+
this.spot = but;
|
|
58793
|
+
|
|
58794
|
+
if (typeof(call) == "function") {
|
|
58795
|
+
var butEvent = but.on(eventType,function(e) {
|
|
58796
|
+
call(e);
|
|
58797
|
+
});
|
|
58798
|
+
}
|
|
58799
|
+
if (typeof(callOver) == "function") {
|
|
58800
|
+
var butOverEvent = but.on("mouseover",function(e) {
|
|
58801
|
+
callOver(e);
|
|
58802
|
+
});
|
|
58803
|
+
}
|
|
58804
|
+
if (typeof(callOut) == "function") {
|
|
58805
|
+
var butOutEvent = but.on("mouseout",function(e) {
|
|
58806
|
+
callOut(e);
|
|
58807
|
+
});
|
|
58808
|
+
}
|
|
58809
|
+
obj.addChild(but);
|
|
58810
|
+
|
|
58811
|
+
this.show = function() {
|
|
58812
|
+
but.alpha = .5;
|
|
58813
|
+
if (obj.stage) obj.stage.update();
|
|
58814
|
+
};
|
|
58815
|
+
this.hide = function() {
|
|
58816
|
+
but.alpha = 0;
|
|
58817
|
+
if (obj.stage) obj.stage.update();
|
|
58818
|
+
};
|
|
58819
|
+
this.dispose = function() {
|
|
58820
|
+
if (butEvent) but.off(eventType, butOverEvent);
|
|
58821
|
+
if (butOverEvent) but.off("mouseover", butOverEvent);
|
|
58822
|
+
if (butOutEvent) but.off("mouseout", butOutEvent);
|
|
58823
|
+
obj.removeChild(but);
|
|
58824
|
+
but = null;
|
|
58825
|
+
return true;
|
|
58826
|
+
};
|
|
58827
|
+
};
|
|
58828
|
+
zim.extend(zim.HotSpot, zim.Container, "dispose", "zimContainer", false);
|
|
58829
|
+
//-73
|
|
58830
|
+
|
|
58692
58831
|
/*--
|
|
58693
58832
|
zim.HotSpots = function(spots, local, mouseDowns)
|
|
58694
58833
|
|
|
@@ -58705,25 +58844,20 @@ NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set
|
|
|
58705
58844
|
|
|
58706
58845
|
EXAMPLE
|
|
58707
58846
|
// our first hotSpot will be a 50 pixel square at 100, 100
|
|
58708
|
-
// then we will add hotSpots to these items as well
|
|
58709
|
-
var circle = new Circle(60, red);
|
|
58710
|
-
circle.center();
|
|
58711
58847
|
|
|
58712
|
-
|
|
58713
|
-
|
|
58714
|
-
button
|
|
58715
|
-
button.y = H - button.height - 100;
|
|
58848
|
+
// then we will add hotSpots to these items as well
|
|
58849
|
+
const circle = new Circle(60, red).center();
|
|
58850
|
+
const button = new Button().pos(100,100,RIGHT,BOTTOM);
|
|
58716
58851
|
|
|
58717
58852
|
// make the hotSpots object
|
|
58718
58853
|
// these are all on the same page
|
|
58719
58854
|
// gets really handy when you have multiple pages with Pages
|
|
58720
58855
|
const hs = new HotSpots([
|
|
58721
|
-
{page:
|
|
58722
|
-
{page:
|
|
58723
|
-
{page:
|
|
58856
|
+
{page:S, rect:[100,100,50,50], call:()=>{zog("hot!");}},
|
|
58857
|
+
{page:S, rect:circle, call:()=>{zog("circle!");}},
|
|
58858
|
+
{page:S, rect:button, call:()=>{zog("button!");}},
|
|
58724
58859
|
]);
|
|
58725
58860
|
// hs.show(); // uncomment this to see rectangle hotSpots
|
|
58726
|
-
S.update();
|
|
58727
58861
|
END EXAMPLE
|
|
58728
58862
|
|
|
58729
58863
|
PARAMETERS supports DUO - parameters or single object with properties below
|
|
@@ -58901,125 +59035,6 @@ the class creates HotSpot objects - see the class underneath this one
|
|
|
58901
59035
|
//-72
|
|
58902
59036
|
|
|
58903
59037
|
|
|
58904
|
-
/*--
|
|
58905
|
-
zim.HotSpot = function(obj, x, y, width, height, call, callOver, callOut, local, talk)
|
|
58906
|
-
|
|
58907
|
-
HotSpot
|
|
58908
|
-
zim class - extends a zim.Container which extends a createjs.Container
|
|
58909
|
-
|
|
58910
|
-
DESCRIPTION
|
|
58911
|
-
HotSpot adds an invisible button to a container object (often think of this as the page).
|
|
58912
|
-
If you want multiple spots it is more efficient to use the HotSpots class above
|
|
58913
|
-
which manages multiple HotSpot objects (otherwise you end up with multiple event functions).
|
|
58914
|
-
The spot is a pixel rect with an alpha of .01 and then uses a hitArea of a backing shape.
|
|
58915
|
-
The spot will get a cursor of "pointer".
|
|
58916
|
-
|
|
58917
|
-
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
58918
|
-
|
|
58919
|
-
EXAMPLE
|
|
58920
|
-
const hs = new HotSpot(stage, 100, 100, 50, 50, myFunction);
|
|
58921
|
-
function myFunction() {
|
|
58922
|
-
zog("activation!");
|
|
58923
|
-
}
|
|
58924
|
-
// hs.show(); // uncomment this to see rectangle hotSpot
|
|
58925
|
-
S.update();
|
|
58926
|
-
END EXAMPLE
|
|
58927
|
-
|
|
58928
|
-
PARAMETERS supports DUO - parameters or single object with properties below
|
|
58929
|
-
holder - container object in which to place the hotspot (stage for instance)
|
|
58930
|
-
x, y, width and height - of the rectangle for the hotspot
|
|
58931
|
-
call - the function to call when the spot is pressed
|
|
58932
|
-
local - (default true) hotSpot rect is based on local coordinates of the container
|
|
58933
|
-
use when the element scale independently from the stage
|
|
58934
|
-
if set to false then you pass in global coordinates and hotSpot will convert them
|
|
58935
|
-
talk - (default "hotspot") text for ZIM Accessibility screen reader
|
|
58936
|
-
|
|
58937
|
-
METHODS
|
|
58938
|
-
show() - helps when creating the spot to see where it is
|
|
58939
|
-
hide() - hides the hotspot
|
|
58940
|
-
dispose() - removes the listener and the spot
|
|
58941
|
-
|
|
58942
|
-
PROPERTIES
|
|
58943
|
-
type - holds the class name as a String
|
|
58944
|
-
spot - the actual hotSpot object that gets added to the container can be accessed with the spot property
|
|
58945
|
-
eg. hs.spot
|
|
58946
|
-
|
|
58947
|
-
ACTIONEVENT
|
|
58948
|
-
This component is affected by the general ACTIONEVENT setting
|
|
58949
|
-
The default is "mousedown" - if set to something else the component will act on click (press)
|
|
58950
|
-
--*///+73
|
|
58951
|
-
zim.HotSpot = function(obj, x, y, width, height, call, callOver, callOut, local, talk) {
|
|
58952
|
-
var sig = "obj, x, y, width, height, call, callOver, callOut, local, talk";
|
|
58953
|
-
var duo; if (duo = zob(zim.HotSpot, arguments, sig, this)) return duo;
|
|
58954
|
-
z_d("73");
|
|
58955
|
-
this.zimContainer_constructor(null,null,null,null,false);
|
|
58956
|
-
this.type = "HotSpot";
|
|
58957
|
-
|
|
58958
|
-
if (zot(obj) || !obj.addChild) {zogy("zim controls - HotSpot():\nPlease pass in container object for obj"); return;}
|
|
58959
|
-
if (obj instanceof createjs.Container == false) {zogy("zim controls - HotSpot():\nObjects passed in should be Containers"); return;}
|
|
58960
|
-
if (zot(x) || zot(y) || zot(width) || zot(height)) {zogy("zim controls - HotSpot():\nPlease pass in x, y, width, height"); return;}
|
|
58961
|
-
if (zot(local)) local = true;
|
|
58962
|
-
var eventType = (!zns?WW.ACTIONEVENT=="mousedown":zim.ACTIONEVENT=="mousedown")?"mousedown":"click";
|
|
58963
|
-
|
|
58964
|
-
var w = width; var h = height;
|
|
58965
|
-
var point,newW,newH;
|
|
58966
|
-
if (!local) {
|
|
58967
|
-
point = obj.globalToLocal(x,y);
|
|
58968
|
-
var point2 = obj.globalToLocal(x+w,y+h);
|
|
58969
|
-
newW = point2.x-point.x;
|
|
58970
|
-
newH = point2.y-point.y;
|
|
58971
|
-
} else {
|
|
58972
|
-
point = new zim.Point(x,y);
|
|
58973
|
-
newW = width;
|
|
58974
|
-
newH = height;
|
|
58975
|
-
}
|
|
58976
|
-
var but = new zim.Shape(width, height);
|
|
58977
|
-
but.talk = zot(talk)?"HotSpot":talk;
|
|
58978
|
-
but.alpha = 0;
|
|
58979
|
-
but.graphics.f("black").dr(0,0,newW,newH);
|
|
58980
|
-
but.x = point.x;
|
|
58981
|
-
but.y = point.y;
|
|
58982
|
-
but.cur("pointer");
|
|
58983
|
-
but.expand(0);
|
|
58984
|
-
this.spot = but;
|
|
58985
|
-
|
|
58986
|
-
if (typeof(call) == "function") {
|
|
58987
|
-
var butEvent = but.on(eventType,function(e) {
|
|
58988
|
-
call(e);
|
|
58989
|
-
});
|
|
58990
|
-
}
|
|
58991
|
-
if (typeof(callOver) == "function") {
|
|
58992
|
-
var butOverEvent = but.on("mouseover",function(e) {
|
|
58993
|
-
callOver(e);
|
|
58994
|
-
});
|
|
58995
|
-
}
|
|
58996
|
-
if (typeof(callOut) == "function") {
|
|
58997
|
-
var butOutEvent = but.on("mouseout",function(e) {
|
|
58998
|
-
callOut(e);
|
|
58999
|
-
});
|
|
59000
|
-
}
|
|
59001
|
-
obj.addChild(but);
|
|
59002
|
-
|
|
59003
|
-
this.show = function() {
|
|
59004
|
-
but.alpha = .5;
|
|
59005
|
-
if (obj.stage) obj.stage.update();
|
|
59006
|
-
};
|
|
59007
|
-
this.hide = function() {
|
|
59008
|
-
but.alpha = 0;
|
|
59009
|
-
if (obj.stage) obj.stage.update();
|
|
59010
|
-
};
|
|
59011
|
-
this.dispose = function() {
|
|
59012
|
-
if (butEvent) but.off(eventType, butOverEvent);
|
|
59013
|
-
if (butOverEvent) but.off("mouseover", butOverEvent);
|
|
59014
|
-
if (butOutEvent) but.off("mouseout", butOutEvent);
|
|
59015
|
-
obj.removeChild(but);
|
|
59016
|
-
but = null;
|
|
59017
|
-
return true;
|
|
59018
|
-
};
|
|
59019
|
-
};
|
|
59020
|
-
zim.extend(zim.HotSpot, zim.Container, "dispose", "zimContainer", false);
|
|
59021
|
-
//-73
|
|
59022
|
-
|
|
59023
59038
|
/*--
|
|
59024
59039
|
zim.Guide = function(obj, vertical, pixels, hideKey, pixelKey, style, group, inherit)
|
|
59025
59040
|
|
|
@@ -61616,7 +61631,7 @@ note: the item is not the event object target - as that is the tile
|
|
|
61616
61631
|
if (style!==false) zim.styleTransforms(this, DS); // global function - would have put on DisplayObject if had access to it
|
|
61617
61632
|
|
|
61618
61633
|
this.clone = function(exact) {
|
|
61619
|
-
if (unique) exact = true; // added ZIM 016
|
|
61634
|
+
if (zot(exact) && unique) exact = true; // added ZIM 016
|
|
61620
61635
|
if (exact) {
|
|
61621
61636
|
var exactItems = [];
|
|
61622
61637
|
if (backgroundColor) var exactBackgroundColors = [];
|
|
@@ -69758,11 +69773,24 @@ join(obj1, obj2, point1, point2, minAngle, maxAngle, type) - creates and returns
|
|
|
69758
69773
|
break(joint) - break a joint created with join()
|
|
69759
69774
|
to use, store the result of the join() method in a variable and pass that variable in to break()
|
|
69760
69775
|
attach(control, obj) attach a physics object (obj) to a ZIM object (control) to like a mousejoint to the ZIM object not the mouse
|
|
69761
|
-
|
|
69762
|
-
|
|
69763
|
-
|
|
69764
|
-
|
|
69776
|
+
the control can then be animated, wiggled, dragged and the physics object will follow it
|
|
69777
|
+
returns an id to be able to unattach
|
|
69778
|
+
const id = physics.attach(triangle, circle);
|
|
69779
|
+
timeout(2, ()=>{physics.unattach(id)});
|
|
69765
69780
|
unattach(id) unattach a physics object from the ZIM object based on the stored id from attach();
|
|
69781
|
+
buoyancy(height, denisity, linear, angular) returns a Box2D buoyancy controller. Then need to add() or remove() objects
|
|
69782
|
+
height - (default H/2) is pixels from bottom of the stage
|
|
69783
|
+
density - (default 3) density of fluid - the higher the more an object floats
|
|
69784
|
+
linear - (default 4) linear damping to reduce movement
|
|
69785
|
+
angular - (default 4) angular damping to reduce rotation
|
|
69786
|
+
the buoyancy controller will have the following methods:
|
|
69787
|
+
add(obj) - add object with physics or an array of objects with physics to buoyancy controller
|
|
69788
|
+
returns buoyancy object for chaining
|
|
69789
|
+
remove(obj) - remove object or an array of objects from buoyancy controller
|
|
69790
|
+
returns buoyancy object for chaining
|
|
69791
|
+
clear() - remove all objects from buoyancy controller
|
|
69792
|
+
returns buoyancy object for chaining
|
|
69793
|
+
dispose() - deletes buoyancy controller
|
|
69766
69794
|
debug() - activates the debugging - returns object for chaining
|
|
69767
69795
|
updateDebug() - updates the debug canvas if the frame has been scaled (put in frame resize event)
|
|
69768
69796
|
removeDebug() - removes the debug canvas - you can add it again later (or toggle, etc.)
|
|
@@ -69918,12 +69946,15 @@ dynamic - set to true for dynamic and false for static
|
|
|
69918
69946
|
speed - get or set the speed of an object that is controlled by control()
|
|
69919
69947
|
speedY - get or set the speedY of an object that is controlled by control()
|
|
69920
69948
|
** normal x, y, rotation or pos(), loc(), rot() will not work with physics!
|
|
69921
|
-
** see the BODY
|
|
69949
|
+
** see the BODY loc(x,y) METHOD and the rotation PROPERTY below
|
|
69922
69950
|
** these should really not be set at all in the physics world
|
|
69923
69951
|
** but rather let the forces, etc. work them out
|
|
69924
69952
|
** it is best to set traditional properties before calling physics()
|
|
69925
69953
|
|
|
69926
69954
|
METHODS - FOR BODY (a physics engine body)
|
|
69955
|
+
loc(x,y) - generally, we should not manually adjust x and y but rather use forces
|
|
69956
|
+
but for resetting things, etc. use zimObj.body.loc(x, y)
|
|
69957
|
+
Do not use zimObj.loc() or zimObj.x or zimObj.y - these will only work BEFORE adding physics.
|
|
69927
69958
|
** the ZIM DisplayObject body property provides access to the following Box2D methods (note, all start with uppercase):
|
|
69928
69959
|
** commonly used methods are handled through ZIM wrapper methods on the DisplayObject
|
|
69929
69960
|
** see https://www.box2dflash.org/docs/2.1a/reference/ for very basic docs
|
|
@@ -69942,9 +69973,11 @@ PROPERTIES - FOR BODY (a physics engine body)
|
|
|
69942
69973
|
zimObj - the ZIM Object that the body is mapped to
|
|
69943
69974
|
** traditional properties should be set before calling phyics()
|
|
69944
69975
|
** but the following properties are provided
|
|
69945
|
-
x -
|
|
69946
|
-
y -
|
|
69976
|
+
x - deprecated - please use the BODY's loc(x, y) method - note: zimObj.body.loc() is not the same as the zimObj.loc() method
|
|
69977
|
+
y - deprecated - please use the BODY's loc(x, y) method - note: zimObj.body.loc() is not the same as the zimObj.loc() method
|
|
69947
69978
|
rotation - the rotation of the body (degrees) - setting this will also rotate the ZIM DisplayObject
|
|
69979
|
+
Also see obj.body.SetFixedRotation() to stop the physics body from rotating https://zimjs.com/zapp/print/Z_C6SBW
|
|
69980
|
+
And the counter rotation technique here: https://zimjs.com/data/
|
|
69948
69981
|
|
|
69949
69982
|
GLOBAL VARIABLES
|
|
69950
69983
|
** Making a new Physics() or using physics() on a ZIM DisplayObject
|
|
@@ -79092,7 +79125,7 @@ the result of the play() or tone() method will dispatch a "complete" event when
|
|
|
79092
79125
|
}, (releaseTime+1)*1000);
|
|
79093
79126
|
};
|
|
79094
79127
|
// if (duration) this.stop(startTime+duration-.1);
|
|
79095
|
-
if (duration) setTimeout(function () {
|
|
79128
|
+
if (duration) setTimeout(function () { // reverted back to this in ZIM 015
|
|
79096
79129
|
that2.stop();
|
|
79097
79130
|
}, (duration-.1) * 1000);
|
|
79098
79131
|
|
|
@@ -84497,7 +84530,9 @@ dispatches "start", "end" and "error" on the utterance object returned by talk()
|
|
|
84497
84530
|
|
|
84498
84531
|
var SpeechRecognition = SpeechRecognition || webkitSpeechRecognition;
|
|
84499
84532
|
var SpeechGrammarList = SpeechGrammarList || window.webkitSpeechGrammarList;
|
|
84500
|
-
|
|
84533
|
+
// this is causing an error on firefox even though they use this in their examples
|
|
84534
|
+
// and we have all the speec about:config setting set to true
|
|
84535
|
+
// var SpeechRecognitionEvent = SpeechRecognitionEvent || webkitSpeechRecognitionEvent;
|
|
84501
84536
|
var recognition = this.recognition = new SpeechRecognition();
|
|
84502
84537
|
recognition.continuous = false;
|
|
84503
84538
|
recognition.lang = this.language = "en-US";
|
|
@@ -90872,8 +90907,8 @@ export let outline = zim.outline;
|
|
|
90872
90907
|
export let blendmodes = zim.blendmodes;
|
|
90873
90908
|
export let Pages = zim.Pages;
|
|
90874
90909
|
export let Arrow = zim.Arrow;
|
|
90875
|
-
export let HotSpots = zim.HotSpots;
|
|
90876
90910
|
export let HotSpot = zim.HotSpot;
|
|
90911
|
+
export let HotSpots = zim.HotSpots;
|
|
90877
90912
|
export let Guide = zim.Guide;
|
|
90878
90913
|
export let Grid = zim.Grid;
|
|
90879
90914
|
export let Wrapper = zim.Wrapper;
|
|
@@ -90948,4 +90983,4 @@ export let Ticker = zim.Ticker;
|
|
|
90948
90983
|
export let Style = zim.Style;
|
|
90949
90984
|
export let assets = zim.assets;
|
|
90950
90985
|
export let assetIDs = zim.assetIDs;
|
|
90951
|
-
export let ZIMON = zim.ZIMON;
|
|
90986
|
+
export let ZIMON = zim.ZIMON;
|
|
@@ -3616,8 +3616,12 @@ declare namespace zim {
|
|
|
3616
3616
|
borders(boundary?: Boundary | {}): void
|
|
3617
3617
|
drag(array?: [any]): void
|
|
3618
3618
|
noDrag(): void
|
|
3619
|
+
pause(type?:boolean): void;
|
|
3619
3620
|
join(obj1: DisplayObject, obj2: DisplayObject, point1?: Point | {}, point2?: Point | {}, minAngle?: number, maxAngle?: number, type?: string): any
|
|
3620
3621
|
break(joint: any): void
|
|
3622
|
+
attach(control:DisplayObject, obj:DisplayObject):string
|
|
3623
|
+
unattach(id:string):void
|
|
3624
|
+
buoyancy(height?:number, denisity?:number, linear?:number, angular?:number):any
|
|
3621
3625
|
debug(): void
|
|
3622
3626
|
updateDebug(): void
|
|
3623
3627
|
removeDebug(): void
|