zimjs 16.0.0 → 16.0.2
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 +220 -108
- package/ts-src/typings/zim/index.d.ts +1 -0
package/package.json
CHANGED
package/src/zim.js
CHANGED
|
@@ -2113,7 +2113,7 @@ pauseTimeLeft - if paused, get how much time is left once unpaused
|
|
|
2113
2113
|
}
|
|
2114
2114
|
}
|
|
2115
2115
|
var pausedTimeout;
|
|
2116
|
-
obj.type = "
|
|
2116
|
+
obj.type = "intervalObject";
|
|
2117
2117
|
obj.pause = function(state, immediate, reset) {
|
|
2118
2118
|
if (zot(state)) state = true;
|
|
2119
2119
|
if (state) { // pausing
|
|
@@ -7470,10 +7470,10 @@ const rotation = {min:10, max:20, integer:false, negative:true};
|
|
|
7470
7470
|
// or this can be passed into an animation object
|
|
7471
7471
|
// and then into zim.Emitter() for the animate parameter
|
|
7472
7472
|
|
|
7473
|
-
const emitter = new
|
|
7473
|
+
const emitter = new Emitter({
|
|
7474
7474
|
obj:new Rectangle(),
|
|
7475
7475
|
random:{rotation:rotation} // the emitter will use Pick.choose() to pick a rotation for each particle
|
|
7476
|
-
});
|
|
7476
|
+
}).center();
|
|
7477
7477
|
|
|
7478
7478
|
function age() {
|
|
7479
7479
|
// assuming user.age is some input value that exists
|
|
@@ -8725,7 +8725,27 @@ See the CreateJS documentation for x, y, alpha, rotation, on(), addChild(), etc.
|
|
|
8725
8725
|
|
|
8726
8726
|
NOTE: as of ZIM 5.5.0 the zim namespace is no longer required (unless zns is set to true before running zim)
|
|
8727
8727
|
|
|
8728
|
+
EXAMPLE
|
|
8729
|
+
const container = new Container().loc(100,100);
|
|
8730
|
+
|
|
8731
|
+
// demonstration of adding drag() to a Container
|
|
8732
|
+
const rect = new Rectangle(100, 100, blue)
|
|
8733
|
+
.addTo(container); // add rectangle to container
|
|
8734
|
+
const circle = new Circle(40, red)
|
|
8735
|
+
.center(container) // add the circle to the container and center
|
|
8736
|
+
container.drag(); // will drag either the rectangle or the circle
|
|
8737
|
+
container.drag({all:true}); // will drag both the rectangle and the circle
|
|
8738
|
+
|
|
8739
|
+
// below will reduce the alpha of the object in the container that was clicked (target)
|
|
8740
|
+
container.on("click", e => {e.target.alpha = .5; S.update();});
|
|
8741
|
+
|
|
8742
|
+
// below will reduce the alpha of all the objects in the container (currentTarget)
|
|
8743
|
+
container.on("click", e => {e.currentTarget.alpha = .5; S.update();});
|
|
8744
|
+
END EXAMPLE
|
|
8745
|
+
|
|
8728
8746
|
EXAMPLE
|
|
8747
|
+
// Here we apply the normalize() method of the Container to a Tile (which is a Container)
|
|
8748
|
+
// and scale the children based on the resulting ratio
|
|
8729
8749
|
const tile = new Tile(new Rectangle(70,70,white,black).reg(CENTER), 9, 1, 20)
|
|
8730
8750
|
.normalize("x", CENTER)
|
|
8731
8751
|
.center();
|
|
@@ -8753,6 +8773,7 @@ final.sortBy("ratio"); // make more central objects come to front
|
|
|
8753
8773
|
END EXAMPLE
|
|
8754
8774
|
|
|
8755
8775
|
EXAMPLE
|
|
8776
|
+
// In this case we animate the children based on the rate
|
|
8756
8777
|
// animate() the rate and use sequence:0 to apply different speed to each item
|
|
8757
8778
|
const tile = new Tile(new Rectangle(10, 10, series(green,blue,yellow)), 20, 20, 5, 5)
|
|
8758
8779
|
.normalize("reg", CENTER)
|
|
@@ -13354,7 +13375,7 @@ PROPERTIES
|
|
|
13354
13375
|
type - holds the class name as a String
|
|
13355
13376
|
obj - the original object literal - its properties get updated as the uniforms properties are updated
|
|
13356
13377
|
***
|
|
13357
|
-
Each property in the
|
|
13378
|
+
Each property in the object literal
|
|
13358
13379
|
with arrays being split into a property for each element in the format
|
|
13359
13380
|
name_A, name_B, name_C, name_D as dicted by the number of elements in the value for the property
|
|
13360
13381
|
{year:2024, dimensions:[200,500]}
|
|
@@ -23359,6 +23380,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
23359
23380
|
color = zik(color);
|
|
23360
23381
|
rollColor = zik(rollColor);
|
|
23361
23382
|
downColor = zik(downColor);
|
|
23383
|
+
|
|
23384
|
+
var timeType = zot(WW.TIME) ? zot(zim.TIME) ? "seconds" : zim.TIME : WW.TIME;
|
|
23362
23385
|
|
|
23363
23386
|
var originalBorderColor = borderColor;
|
|
23364
23387
|
var originalBorderWidth = borderWidth;
|
|
@@ -23395,7 +23418,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
23395
23418
|
if (zot(downToggleColor)) downToggleColor=DS.downToggleColor!=null?DS.downToggleColor:label.rollToggleColor;
|
|
23396
23419
|
|
|
23397
23420
|
if (zot(wait)) wait=DS.wait!=null?DS.wait:null;
|
|
23398
|
-
if (zot(waitTime)) waitTime=DS.waitTime!=null?DS.waitTime:
|
|
23421
|
+
if (zot(waitTime)) waitTime=DS.waitTime!=null?DS.waitTime:timeType=="seconds"||timeType=="s"?5:5000;
|
|
23399
23422
|
if (zot(waitBackgroundColor)) waitBackgroundColor=DS.waitBackgroundColor!=null?DS.waitBackgroundColor:backgroundColor;
|
|
23400
23423
|
if (zot(rollWaitBackgroundColor)) rollWaitBackgroundColor=DS.rollWaitBackgroundColor!=null?DS.rollWaitBackgroundColor:rollBackgroundColor;
|
|
23401
23424
|
if (zot(downWaitBackgroundColor)) downWaitBackgroundColor=DS.downWaitBackgroundColor!=null?DS.downWaitBackgroundColor:rollBackgroundColor;
|
|
@@ -23409,7 +23432,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
23409
23432
|
that.focus = false;
|
|
23410
23433
|
that.rolled = false;
|
|
23411
23434
|
|
|
23412
|
-
|
|
23435
|
+
timeType = getTIME(waitTime);
|
|
23413
23436
|
|
|
23414
23437
|
//~~~~~~~~~~~~~ BACKINGS
|
|
23415
23438
|
// also see manual setting of backings beneath getter setter methods
|
|
@@ -26665,6 +26688,7 @@ scrollBar - data object that holds the following properties (with defaults):
|
|
|
26665
26688
|
scrollBar.corner = scrollBar.size / 2;
|
|
26666
26689
|
scrollBar.showTime = .5; // s to fade in
|
|
26667
26690
|
scrollBar.fadeTime = 3; // s to fade out
|
|
26691
|
+
scrollBar.speed = .5 // scrollwheel speed for x and y scrolling with mouse wheel
|
|
26668
26692
|
scrollX - gets and sets the content x position in the window (this will be negative)
|
|
26669
26693
|
scrollY - gets and sets the content y position in the window (this will be negative)
|
|
26670
26694
|
scrollXMax - gets the max we can scroll in x based on content width - window width (plus padding and margin)
|
|
@@ -26865,6 +26889,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
26865
26889
|
scrollBar.corner = scrollBar.size / 2;
|
|
26866
26890
|
scrollBar.showTime = .5;
|
|
26867
26891
|
scrollBar.fadeTime = 3;
|
|
26892
|
+
scrollBar.speed = .5;
|
|
26868
26893
|
|
|
26869
26894
|
if (scrollBarActive) {
|
|
26870
26895
|
var hscrollBar = scrollBar.horizontal = new zim.Shape({style:false});
|
|
@@ -27011,8 +27036,18 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
27011
27036
|
|
|
27012
27037
|
clearTimeout(that.d2Timeout);
|
|
27013
27038
|
that.d2Timeout = setTimeout(function(){
|
|
27014
|
-
|
|
27015
|
-
|
|
27039
|
+
try {
|
|
27040
|
+
if (content && hscrollBar && hscrollBar.proportion) content.x = hscrollBar.proportion.convert(hscrollBar.x);
|
|
27041
|
+
if (content && vscrollBar && vscrollBar.proportion) content.y = vscrollBar.proportion.convert(vscrollBar.y);
|
|
27042
|
+
} catch (err) {
|
|
27043
|
+
clearTimeout(that.d2Timeout);
|
|
27044
|
+
that.d2Timeout = setTimeout(function(){
|
|
27045
|
+
try {
|
|
27046
|
+
if (content && hscrollBar && hscrollBar.proportion) content.x = hscrollBar.proportion.convert(hscrollBar.x);
|
|
27047
|
+
if (content && vscrollBar && vscrollBar.proportion) content.y = vscrollBar.proportion.convert(vscrollBar.y);
|
|
27048
|
+
} catch (err) {}
|
|
27049
|
+
}, 50);
|
|
27050
|
+
}
|
|
27016
27051
|
}, 50);
|
|
27017
27052
|
clearTimeout(that.dTimeout);
|
|
27018
27053
|
that.dTimeout = setTimeout(function(){setdragBoundary();}, 300);
|
|
@@ -27555,22 +27590,41 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
27555
27590
|
}
|
|
27556
27591
|
|
|
27557
27592
|
var desiredY = that.scrollY;
|
|
27593
|
+
var desiredX = that.scrollX;
|
|
27558
27594
|
that.scrollWindow = function scrollWindow(e) {
|
|
27559
|
-
if (
|
|
27595
|
+
if (that.stage && that.hitTestPoint(that.windowMouseX, that.windowMouseY) && that.contains(that.stage.getObjectUnderPoint(that.windowMouseX*zim.scaX, that.windowMouseY*zim.scaY))) {
|
|
27596
|
+
var delta;
|
|
27597
|
+
var deltaY;
|
|
27598
|
+
var deltaX;
|
|
27560
27599
|
if (zot(e)) e = event;
|
|
27561
|
-
|
|
27562
|
-
|
|
27563
|
-
|
|
27564
|
-
|
|
27565
|
-
if (
|
|
27566
|
-
|
|
27567
|
-
|
|
27600
|
+
|
|
27601
|
+
deltaY = (that.stage && that.stage.frame.shiftKey) ? e.deltaX : e.deltaY;
|
|
27602
|
+
deltaX = (that.stage && that.stage.frame.shiftKey) ? e.deltaY : e.deltaX;
|
|
27603
|
+
|
|
27604
|
+
if (vCheck && deltaY != null) {
|
|
27605
|
+
// var delta = e.detail ? e.detail*(-19) : e.wheelDelta;
|
|
27606
|
+
delta = deltaY*(-that.scrollBar.speed);
|
|
27607
|
+
desiredY += delta;
|
|
27608
|
+
desiredY = Math.max(-that.scrollYMax, Math.min(0, desiredY));
|
|
27609
|
+
if (!damp) that.scrollY = desiredY;
|
|
27568
27610
|
}
|
|
27569
|
-
|
|
27570
|
-
|
|
27611
|
+
if (hCheck && deltaX != null) {
|
|
27612
|
+
// var delta = e.detail ? e.detail*(-19) : e.wheelDelta;
|
|
27613
|
+
delta = deltaX*(-that.scrollBar.speed);
|
|
27614
|
+
desiredX += delta;
|
|
27615
|
+
desiredX = Math.max(-that.scrollXMax, Math.min(0, desiredX));
|
|
27616
|
+
that.scrollX = desiredX;
|
|
27617
|
+
}
|
|
27618
|
+
if (hCheck || vCheck) {
|
|
27619
|
+
scrollBarDown = false;
|
|
27620
|
+
if (!damp) {
|
|
27621
|
+
content.stage.update();
|
|
27622
|
+
}
|
|
27623
|
+
}
|
|
27624
|
+
}
|
|
27571
27625
|
if (optimize) {
|
|
27572
27626
|
testContent();
|
|
27573
|
-
}
|
|
27627
|
+
}
|
|
27574
27628
|
}
|
|
27575
27629
|
if (scrollWheel) {
|
|
27576
27630
|
WW.addEventListener("mousewheel", that.scrollWindow);
|
|
@@ -30439,8 +30493,9 @@ list - (default Options 1-30) an array of strings, numbers or zim Label objects
|
|
|
30439
30493
|
See: https://zimjs.com/ten/accordion.html
|
|
30440
30494
|
note: the Accordion List is currently incompatible with the Organizer, addTo() and removeFrom()
|
|
30441
30495
|
viewNum - (default 5) how many items to show in the width and height provided
|
|
30442
|
-
adjusting this number will also change the overall scale of custom items
|
|
30443
|
-
|
|
30496
|
+
adjusting this number will also change the overall scale of custom items for horizontal lists
|
|
30497
|
+
(this does not affect vertical lists due to the way vertical tabs are optimized)
|
|
30498
|
+
or see the noScale parameter to avoid scaling custom items in horizontal lists
|
|
30444
30499
|
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
|
|
30445
30500
|
vertical - (default true) set to false to make a horizontal list
|
|
30446
30501
|
currentSelected - (default false) set to true to show the current selection as highlighted
|
|
@@ -30787,7 +30842,6 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
30787
30842
|
listW = list;
|
|
30788
30843
|
}
|
|
30789
30844
|
|
|
30790
|
-
|
|
30791
30845
|
// handle possible checkboxes
|
|
30792
30846
|
if (checkBox) {
|
|
30793
30847
|
zim.loop(listW, function (item, i) {
|
|
@@ -30879,18 +30933,20 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
30879
30933
|
organizer.addTo(that).loc(0,-organizer.height);
|
|
30880
30934
|
}
|
|
30881
30935
|
|
|
30936
|
+
|
|
30882
30937
|
if (customWidth && noScale) {
|
|
30883
|
-
|
|
30884
|
-
|
|
30885
|
-
that.itemWidth = vertical?(width-(scrollBarActive?(scrollBarOverlay?0:6):0)):customWidth/listW.length;
|
|
30886
|
-
that.itemHeight = vertical?customHeight/listW.length:(height-(scrollBarActive?(scrollBarOverlay?0:6):0));
|
|
30938
|
+
that.itemWidth = vertical?(width-paddingH*2-(scrollBarActive?(scrollBarOverlay?0:6):0)):customWidth/listW.length;
|
|
30939
|
+
that.itemHeight = vertical?customHeight/listW.length:(height-paddingV*2-(scrollBarActive?(scrollBarOverlay?0:6):0));
|
|
30940
|
+
// that.itemWidth = vertical?(width-(scrollBarActive?(scrollBarOverlay?0:6):0)):customWidth/listW.length;
|
|
30941
|
+
// that.itemHeight = vertical?customHeight/listW.length:(height-(scrollBarActive?(scrollBarOverlay?0:6):0));
|
|
30887
30942
|
|
|
30888
30943
|
} else {
|
|
30889
|
-
|
|
30890
|
-
|
|
30891
|
-
that.itemWidth = vertical?(width-(scrollBarActive?(scrollBarOverlay?0:6):0)):(width)/viewNum;
|
|
30892
|
-
that.itemHeight = vertical?(height)/viewNum:(height-(scrollBarActive?(scrollBarOverlay?0:6):0));
|
|
30944
|
+
that.itemWidth = vertical?(width-paddingH*2-(scrollBarActive?(scrollBarOverlay?0:6):0)):(width-paddingH*2)/viewNum;
|
|
30945
|
+
that.itemHeight = vertical?(height-paddingV*2)/viewNum:(height-paddingV*2-(scrollBarActive?(scrollBarOverlay?0:6):0));
|
|
30946
|
+
// that.itemWidth = vertical?(width-(scrollBarActive?(scrollBarOverlay?0:6):0)):(width)/viewNum;
|
|
30947
|
+
// that.itemHeight = vertical?(height)/viewNum:(height-(scrollBarActive?(scrollBarOverlay?0:6):0));
|
|
30893
30948
|
}
|
|
30949
|
+
|
|
30894
30950
|
var tabs;
|
|
30895
30951
|
var inheritedStyles = zim.copy(DS);
|
|
30896
30952
|
delete inheritedStyles.borderWidth;
|
|
@@ -30936,11 +30992,11 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
30936
30992
|
.mov(vertical?0:paddingH,vertical?paddingV:0);
|
|
30937
30993
|
// var b = tabs.getBounds();
|
|
30938
30994
|
// tabs.setBounds(0,0,vertical?b.width:(b.width+spacing*2+4),vertical?(b.height+spacing*2+4):b.height);
|
|
30939
|
-
that.add(tabs);
|
|
30995
|
+
that.add(tabs);
|
|
30940
30996
|
// tabs.loc(paddingH, paddingV)
|
|
30941
30997
|
zim.loop(tabs.labels, function (label) {
|
|
30942
30998
|
if (label) label.backgroundColor = zim.clear;
|
|
30943
|
-
})
|
|
30999
|
+
});
|
|
30944
31000
|
}
|
|
30945
31001
|
makeTabs(zim.copy(listW, clone));
|
|
30946
31002
|
|
|
@@ -30952,7 +31008,8 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
30952
31008
|
if (point.y - that.tabs.buttons[that.tabs.buttons.length-1].height <= height - that.tabs.height) {that.tabs.y += that.tabs.height/2 + spacing/2}
|
|
30953
31009
|
|
|
30954
31010
|
} else {
|
|
30955
|
-
|
|
31011
|
+
if (point.x >= -that.tabs.buttons[0].width) {that.tabs.x -= that.tabs.width/2 + spacing/2}
|
|
31012
|
+
if (point.x - that.tabs.buttons[that.tabs.buttons.length-1].width <= width - that.tabs.width) {that.tabs.x += that.tabs.width/2 + spacing/2}
|
|
30956
31013
|
}
|
|
30957
31014
|
// zog(point.y)
|
|
30958
31015
|
// zogy(that.tabs.buttons[0].height, that.tabs.buttons[that.tabs.buttons.length-1].height)
|
|
@@ -34891,7 +34948,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
34891
34948
|
var num = tabs.length;
|
|
34892
34949
|
var tabW = (width - spacing*(num-1))/num;
|
|
34893
34950
|
var tabH = (height - spacing*(num-1)-2)/num;
|
|
34894
|
-
|
|
34951
|
+
|
|
34895
34952
|
if (!zot(backdropColor)) {
|
|
34896
34953
|
// may be resized later
|
|
34897
34954
|
var backdrop = this.backdrop = new zim.Rectangle(width,height,backdropColor, null, null, null, null, null, null, false);
|
|
@@ -43011,6 +43068,20 @@ loader.on("loaded", e=>{
|
|
|
43011
43068
|
});
|
|
43012
43069
|
END EXAMPLE
|
|
43013
43070
|
|
|
43071
|
+
EXAMPLE
|
|
43072
|
+
// save a json file
|
|
43073
|
+
const obj = {a:[1,2,3], b:"hello"};
|
|
43074
|
+
new Loader().save({content:obj, type:"json"}); // save a json file with obj
|
|
43075
|
+
END EXAMPLE
|
|
43076
|
+
|
|
43077
|
+
EXAMPLE
|
|
43078
|
+
// save a text file
|
|
43079
|
+
const textInput = new TextInput().center();
|
|
43080
|
+
new Button({label:"SUBMIT", wait:"SAVED"}).center().mov(0,100).tap(()=>{
|
|
43081
|
+
new Loader().save({content:textInput.text, filename:"answer.txt", type:"text"});
|
|
43082
|
+
});
|
|
43083
|
+
END EXAMPLE
|
|
43084
|
+
|
|
43014
43085
|
PARAMETERS
|
|
43015
43086
|
** supports DUO - parameters or single object with properties below
|
|
43016
43087
|
** supports OCT - parameter defaults can be set with STYLE control (like CSS)
|
|
@@ -43066,14 +43137,17 @@ resize() - call the resize event if the scale or position of the Loader is chang
|
|
|
43066
43137
|
Note: if the Frame itself changes location in the HTML document, call a F.update()
|
|
43067
43138
|
this will then dispatch an update event to the Loader and it will resize()
|
|
43068
43139
|
this is not needed if resizing the window or scrolling - see Frame update() method docs
|
|
43069
|
-
save(content, filename, x, y, width, height, cached, cachedBounds, type, data, quality) - save a picture (supports ZIM DUO)
|
|
43070
|
-
content - the Display object to be saved such as a Container, Bitmap, etc.
|
|
43140
|
+
save(content, filename, x, y, width, height, cached, cachedBounds, type, data, quality) - save a picture or text (supports ZIM DUO)
|
|
43141
|
+
content - the Display object to be saved such as a Container, Bitmap, etc.
|
|
43142
|
+
or text (or Label, TextInput, TextArea) or JSON or object for JSON
|
|
43143
|
+
if text or json, then x, y, width, height, cached, cachedBounds, data, and quality are ignored
|
|
43071
43144
|
filename - (default random) - the text name of the file (with or without extension - also see type)
|
|
43072
43145
|
x, y, width, height - the cropping bounds on that object otherwise defaults to 0,0,W,H
|
|
43073
43146
|
cached - (default false) set to true if the object is currently already cached
|
|
43074
43147
|
cachedBounds - if you are saving a different bounds than was previously cached
|
|
43075
43148
|
setting the bounds here (createjs.Rectangle) will restore the cache to the previous bounds
|
|
43076
|
-
type - (default "png") set to "jpeg" for jpeg
|
|
43149
|
+
type - (default "png") set to "jpeg" for jpeg or "txt", "text" or "json"
|
|
43150
|
+
json will convert the content to JSON if it is not already in JSON format
|
|
43077
43151
|
data - (default false) set to true to save as base64 data
|
|
43078
43152
|
otherwise save returns the object for chaining
|
|
43079
43153
|
quality - (default .92) a number between 0 an 1 representing the quality of the saved image (jpeg)
|
|
@@ -43405,11 +43479,12 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
43405
43479
|
}
|
|
43406
43480
|
|
|
43407
43481
|
this.save = function(content, filename, x, y, width, height, cached, cachedBounds, type, data, quality) {
|
|
43408
|
-
|
|
43482
|
+
|
|
43409
43483
|
var sig = "content, filename, x, y, width, height, cached, cachedBounds, type, data, quality";
|
|
43410
43484
|
var duo; if (duo = zob(that.save, arguments, sig)) return duo;
|
|
43411
|
-
if (zot(content)) content = frame.stage;
|
|
43485
|
+
if (zot(content)) content = frame.stage;
|
|
43412
43486
|
|
|
43487
|
+
if (type=="text") type = "txt";
|
|
43413
43488
|
if (zot(type)) type = "png";
|
|
43414
43489
|
if (zot(filename)) {
|
|
43415
43490
|
filename = "saved_" + String(zim.makeID("numbers", 5)) + "." + type;
|
|
@@ -43418,7 +43493,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
43418
43493
|
if (parts.length == 1) {
|
|
43419
43494
|
filename += "." + type;
|
|
43420
43495
|
} else {
|
|
43421
|
-
var types = ["png","jpg","jpeg"];
|
|
43496
|
+
var types = ["png","jpg","jpeg","txt","json"];
|
|
43422
43497
|
var ind = types.indexOf(parts[parts.length-1].toLowerCase());
|
|
43423
43498
|
if (ind == -1) {
|
|
43424
43499
|
filename += "." + type;
|
|
@@ -43427,6 +43502,22 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
|
|
|
43427
43502
|
}
|
|
43428
43503
|
}
|
|
43429
43504
|
}
|
|
43505
|
+
|
|
43506
|
+
if (type=="txt" || type=="json") {
|
|
43507
|
+
// thanks https://www.tutorialspoint.com/how-to-create-and-save-text-file-in-javascript
|
|
43508
|
+
var link = document.createElement("a");
|
|
43509
|
+
var ff;
|
|
43510
|
+
if (typeof content != "string" && content.text) content = content.text;
|
|
43511
|
+
if (type=="json" && !isJSON(content)) content = JSON.stringify(content);
|
|
43512
|
+
if (document && document.Blob) ff = new document.Blob([content], {type:'text/plain'});
|
|
43513
|
+
else ff = new Blob([content], {type:'text/plain'});
|
|
43514
|
+
link.href = URL.createObjectURL(ff);
|
|
43515
|
+
link.download = filename;
|
|
43516
|
+
link.click();
|
|
43517
|
+
URL.revokeObjectURL(link.href);
|
|
43518
|
+
return that;
|
|
43519
|
+
}
|
|
43520
|
+
|
|
43430
43521
|
if (zot(x)) x = 0;
|
|
43431
43522
|
if (zot(y)) y = 0;
|
|
43432
43523
|
if (zot(width)) width = (content.getBounds && content.getBounds()) ? content.getBounds().width : frame.width;
|
|
@@ -46616,7 +46707,6 @@ RETURNS obj for chaining
|
|
|
46616
46707
|
obj.cur("pointer");
|
|
46617
46708
|
var stage;
|
|
46618
46709
|
obj.zimClickHoldDownEvent = obj.on("mousedown", function (e) {
|
|
46619
|
-
zog("here")
|
|
46620
46710
|
if (!stage) stage = e.target.stage;
|
|
46621
46711
|
if (!stage) return;
|
|
46622
46712
|
if (zot(stage.frame)) stage.frame = WW.zdf;
|
|
@@ -47072,7 +47162,11 @@ RETURNS obj for chaining
|
|
|
47072
47162
|
var stCheck = false;
|
|
47073
47163
|
obj.zimDown = obj.on("mousedown", function(e) {
|
|
47074
47164
|
if (!obj.stage || obj.dragPaused) return;
|
|
47075
|
-
if (singleTouch && stCheck)
|
|
47165
|
+
if (singleTouch && stCheck) {
|
|
47166
|
+
e.preventDefault();
|
|
47167
|
+
e.stopImmediatePropagation();
|
|
47168
|
+
return;
|
|
47169
|
+
}; // breaking if coming back from iframe until next mousedown
|
|
47076
47170
|
|
|
47077
47171
|
// obj.zimMove = obj.on("pressmove", obj.zimMove); // for some reason causing squiggle drag problems
|
|
47078
47172
|
|
|
@@ -47163,8 +47257,16 @@ RETURNS obj for chaining
|
|
|
47163
47257
|
}, true);
|
|
47164
47258
|
|
|
47165
47259
|
obj.zimMove = obj.on("pressmove", function(e) {
|
|
47166
|
-
if (singleTouch && !obj.pointers["id"+Math.abs(e.pointerID+1)])
|
|
47167
|
-
|
|
47260
|
+
if (singleTouch && !obj.pointers["id"+Math.abs(e.pointerID+1)]) {
|
|
47261
|
+
e.preventDefault();
|
|
47262
|
+
e.stopImmediatePropagation();
|
|
47263
|
+
return;
|
|
47264
|
+
};
|
|
47265
|
+
if (!obj.downCheck || obj.dragPaused) {
|
|
47266
|
+
e.preventDefault();
|
|
47267
|
+
e.stopImmediatePropagation();
|
|
47268
|
+
return;
|
|
47269
|
+
};
|
|
47168
47270
|
var x = (offStage?e.rawX:e.stageX)/zim.scaX+stage.x;
|
|
47169
47271
|
var y = (offStage?e.rawY:e.stageY)/zim.scaY+stage.y;
|
|
47170
47272
|
obj.dragMouseX = Math.round(x);
|
|
@@ -47257,16 +47359,24 @@ RETURNS obj for chaining
|
|
|
47257
47359
|
|
|
47258
47360
|
obj.zimUp = obj.on("pressup", function(e){doUp(e);}, true);
|
|
47259
47361
|
|
|
47260
|
-
function doUp(e, outsideUp) {
|
|
47362
|
+
function doUp(e, outsideUp) {
|
|
47261
47363
|
|
|
47262
|
-
|
|
47263
|
-
|
|
47364
|
+
if (singleTouch && !outsideUp && !obj.pointers["id"+Math.abs(e.pointerID+1)]) {
|
|
47365
|
+
e.preventDefault();
|
|
47366
|
+
e.stopImmediatePropagation();
|
|
47367
|
+
return;
|
|
47368
|
+
};
|
|
47264
47369
|
|
|
47265
47370
|
stCheck = false;
|
|
47266
47371
|
|
|
47267
47372
|
var id = "id"+Math.abs((!zot(e.pointerID)?e.pointerID:0)+1); // avoiding NaN but not sure if correct ZIM 015
|
|
47268
47373
|
delete obj.pointers[id];
|
|
47269
|
-
|
|
47374
|
+
|
|
47375
|
+
if (!obj.downCheck || obj.dragPaused) {
|
|
47376
|
+
e.preventDefault();
|
|
47377
|
+
e.stopImmediatePropagation();
|
|
47378
|
+
return;
|
|
47379
|
+
};
|
|
47270
47380
|
|
|
47271
47381
|
if (obj.cur) obj.cur(zot(overCursor)?"pointer":overCursor);
|
|
47272
47382
|
else obj.cursor = zot(overCursor)?"pointer":overCursor;
|
|
@@ -52440,7 +52550,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
52440
52550
|
target.percentCompleteCheck = true;
|
|
52441
52551
|
target._percentComplete = 0;
|
|
52442
52552
|
Object.defineProperty(target, 'percentComplete', {
|
|
52443
|
-
get: function() {
|
|
52553
|
+
get: function() {
|
|
52444
52554
|
if (target.paused) return target._percentComplete;
|
|
52445
52555
|
if (target.tweenStartTime && target.tweenEndTime) {
|
|
52446
52556
|
// return if paused and however long is paused gets added to target.tweenStartTime and target.tweenEndTime
|
|
@@ -52672,6 +52782,7 @@ RETURNS the target for chaining (or null if no target is provided and run on zim
|
|
|
52672
52782
|
pathPercent/=2;
|
|
52673
52783
|
if (tween.position > tween.duration/2) pathPercent = 100-pathPercent;
|
|
52674
52784
|
}
|
|
52785
|
+
target._percentComplete = pathPercent
|
|
52675
52786
|
}
|
|
52676
52787
|
|
|
52677
52788
|
if (pathObject) {
|
|
@@ -60771,7 +60882,7 @@ note: the item is not the event object target - as that is the tile
|
|
|
60771
60882
|
if (!rowSize||!zot(height)) h = Math.abs(tB.height);
|
|
60772
60883
|
// if (!colSize||!zot(width)) w = Math.abs(tile.width);
|
|
60773
60884
|
// if (!rowSize||!zot(height)) h = Math.abs(tile.height);
|
|
60774
|
-
|
|
60885
|
+
|
|
60775
60886
|
widthHeights[j][i] = [w,h];
|
|
60776
60887
|
if (zot(widthMax[i])) widthMax[i] = 0;
|
|
60777
60888
|
if (zot(heightMax[j])) heightMax[j] = 0;
|
|
@@ -70609,7 +70720,7 @@ new Pic("image.png") // preloaded asset
|
|
|
70609
70720
|
.center()
|
|
70610
70721
|
.effect(new ShadowEffect())
|
|
70611
70722
|
.animate({
|
|
70612
|
-
props:{"effects.
|
|
70723
|
+
props:{"effects.shadow.angle":90},
|
|
70613
70724
|
time:.7,
|
|
70614
70725
|
rewind:true,
|
|
70615
70726
|
rewindWait:.5,
|
|
@@ -82147,8 +82258,8 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
82147
82258
|
} else {
|
|
82148
82259
|
setCursor();
|
|
82149
82260
|
}
|
|
82150
|
-
if (that.cursorObj != oldCursor && oldCursor.removeFrom) oldCursor.removeFrom();
|
|
82151
|
-
|
|
82261
|
+
if (that.cursorObj != oldCursor && oldCursor.removeFrom) oldCursor.removeFrom();
|
|
82262
|
+
if (!that.cursorObj) return;
|
|
82152
82263
|
that.cursorObj.x = that.mouseX;
|
|
82153
82264
|
that.cursorObj.y = that.mouseY;
|
|
82154
82265
|
that.cursorObj.top();
|
|
@@ -82160,7 +82271,6 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
|
|
|
82160
82271
|
firstSet = true;
|
|
82161
82272
|
var co = that.stage.getObjectUnderPoint(that.mouseX, that.mouseY, 1);
|
|
82162
82273
|
if (co && (co._cursor || co.cursor)) {
|
|
82163
|
-
zog("setting")
|
|
82164
82274
|
setCustom(co);
|
|
82165
82275
|
} else if (obj.default) {
|
|
82166
82276
|
setCursor("none");
|
|
@@ -88364,8 +88474,10 @@ flipMaterial(materialType, params) - flip about the y access a material
|
|
|
88364
88474
|
Note a second texture must be made and passed to flipMaterial in the params as the map
|
|
88365
88475
|
curvePlane(geometry, z) - curves a THREE.PlaneGeometry but a z value (positive or negative)
|
|
88366
88476
|
adjusts the Geometry in place - used internally by makePanel
|
|
88367
|
-
dispose() - stops the renderer
|
|
88368
|
-
|
|
88477
|
+
dispose() - clears geometries, materials, stops the renderer, removes scene and sets internal variables to null
|
|
88478
|
+
make sure the three reference is set to null:
|
|
88479
|
+
myThree.dispose();
|
|
88480
|
+
mythree = null; // same for any dispose - ZIM cannot set your variables to null
|
|
88369
88481
|
METHODS ON MESH
|
|
88370
88482
|
** If makePanel() is used on the ortho scene (ortho parameter true and makeMesh added to three.sceneOrtho)
|
|
88371
88483
|
** then the mesh is given a pos() method:
|
|
@@ -90176,58 +90288,58 @@ for (z_i = 0; z_i < globalFunctions.length; z_i++) {
|
|
|
90176
90288
|
|
|
90177
90289
|
// these are global regardless
|
|
90178
90290
|
var globalsConstants = [
|
|
90179
|
-
|
|
90180
|
-
|
|
90181
|
-
|
|
90182
|
-
|
|
90183
|
-
|
|
90184
|
-
|
|
90185
|
-
|
|
90186
|
-
|
|
90187
|
-
|
|
90188
|
-
|
|
90189
|
-
|
|
90190
|
-
|
|
90191
|
-
|
|
90192
|
-
|
|
90193
|
-
|
|
90194
|
-
|
|
90195
|
-
|
|
90196
|
-
|
|
90197
|
-
|
|
90198
|
-
|
|
90199
|
-
|
|
90200
|
-
|
|
90201
|
-
|
|
90202
|
-
|
|
90203
|
-
|
|
90204
|
-
|
|
90205
|
-
|
|
90206
|
-
|
|
90207
|
-
|
|
90208
|
-
|
|
90209
|
-
|
|
90210
|
-
|
|
90211
|
-
|
|
90212
|
-
|
|
90213
|
-
|
|
90214
|
-
|
|
90215
|
-
|
|
90216
|
-
|
|
90217
|
-
|
|
90218
|
-
|
|
90219
|
-
|
|
90220
|
-
|
|
90221
|
-
|
|
90222
|
-
|
|
90223
|
-
|
|
90224
|
-
|
|
90225
|
-
|
|
90226
|
-
|
|
90227
|
-
|
|
90228
|
-
|
|
90229
|
-
|
|
90230
|
-
|
|
90291
|
+
["FIT", zim.FIT],
|
|
90292
|
+
["FILL", zim.FILL],
|
|
90293
|
+
["FULL", zim.FULL],
|
|
90294
|
+
["LEFT", zim.LEFT],
|
|
90295
|
+
["RIGHT", zim.RIGHT],
|
|
90296
|
+
["CENTER", zim.CENTER],
|
|
90297
|
+
["MIDDLE", zim.MIDDLE],
|
|
90298
|
+
["START", zim.START],
|
|
90299
|
+
["END", zim.END],
|
|
90300
|
+
["TOP", zim.TOP],
|
|
90301
|
+
["BOTTOM", zim.BOTTOM],
|
|
90302
|
+
["OVER", zim.OVER],
|
|
90303
|
+
["UNDER", zim.UNDER],
|
|
90304
|
+
["HORIZONTAL", zim.HORIZONTAL],
|
|
90305
|
+
["VERTICAL", zim.VERTICAL],
|
|
90306
|
+
["BOTH", zim.BOTH],
|
|
90307
|
+
["RADIAL", zim.RADIAL],
|
|
90308
|
+
["UP", zim.UP],
|
|
90309
|
+
["DOWN", zim.DOWN],
|
|
90310
|
+
["NEXT", zim.NEXT],
|
|
90311
|
+
["PREV", zim.PREV],
|
|
90312
|
+
["AUTO", zim.AUTO],
|
|
90313
|
+
["AVE", zim.AVE],
|
|
90314
|
+
["DEFAULT", zim.DEFAULT],
|
|
90315
|
+
["ALL", zim.ALL],
|
|
90316
|
+
["NONE", zim.NONE],
|
|
90317
|
+
["GET", zim.GET],
|
|
90318
|
+
["POST", zim.POST],
|
|
90319
|
+
["LOCALSTORAGE", zim.LOCALSTORAGE],
|
|
90320
|
+
["SOCKET", zim.SOCKET],
|
|
90321
|
+
["TO", zim.TO],
|
|
90322
|
+
["FROM", zim.FROM],
|
|
90323
|
+
["SINE", zim.SINE],
|
|
90324
|
+
["SQUARE", zim.SQUARE],
|
|
90325
|
+
["TRIANGLE", zim.TRIANGLE],
|
|
90326
|
+
["SAW", zim.SAW],
|
|
90327
|
+
["SAWTOOTH", zim.SAWTOOTH],
|
|
90328
|
+
["ZAP", zim.ZAP],
|
|
90329
|
+
["TAU", zim.TAU],
|
|
90330
|
+
["DEG", zim.DEG],
|
|
90331
|
+
["RAD", zim.RAD],
|
|
90332
|
+
["PHI", zim.PHI],
|
|
90333
|
+
];
|
|
90334
|
+
|
|
90335
|
+
for (z_i = 0; z_i < globalsConstants.length; z_i++) {
|
|
90336
|
+
var pair = globalsConstants[z_i];
|
|
90337
|
+
WW[pair[0]] = pair[1];
|
|
90338
|
+
}
|
|
90339
|
+
|
|
90340
|
+
for (z_i = 0; z_i < zim.colors.length; z_i++) {
|
|
90341
|
+
WW[zim.colors[z_i]] = zim.colorsHex[z_i];
|
|
90342
|
+
}
|
|
90231
90343
|
|
|
90232
90344
|
|
|
90233
90345
|
WW.zim = zim;
|