zimjs 17.0.1 → 17.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zimjs",
3
- "version": "17.0.1",
3
+ "version": "17.0.2",
4
4
  "type": "module",
5
5
  "main": "./src/zim.js",
6
6
  "types": "./ts-src/typings/zim",
package/src/zim.js CHANGED
@@ -5317,7 +5317,7 @@ zog(decimals(1.8345, 2)); // 1.83
5317
5317
  zog(decimals(123,-1)); // 120
5318
5318
  zog(decimals(2.3,null,2)); // 2.30
5319
5319
  zog(decimals(3,null,null,2)); // 03
5320
- zog(decimals(.12,2,2,1,null,true)); // 0:12
5320
+ zog(decimals(12/60,2,2,1,null,true)); // 0:12
5321
5321
  END EXAMPLE
5322
5322
 
5323
5323
  PARAMETERS
@@ -5327,6 +5327,7 @@ addZeros - (default 0) set to number of places to fill in zeros after decimal (a
5327
5327
  addZerosBefore - (default 1) set to number of places to fill in zeros before decimal (and return String)
5328
5328
  includeZero - (default true) set to false to always have zero just be 0 without any extra zeros
5329
5329
  time - (default false) a swap of : for . to handle minutes and seconds (not hours)
5330
+ take time in seconds and divide by 60 and pass that in for num
5330
5331
 
5331
5332
  RETURNS a rounded Number or a String if addZeros, addZerosBefore or time is true
5332
5333
  --*///+13
@@ -10468,6 +10469,7 @@ width - gets or sets the width. Setting the width will scale the height to keep
10468
10469
  height - gets or sets the height. Setting the height will scale the width to keep proportion (see heightOnly below)
10469
10470
  widthOnly - gets or sets the width. This sets only the width and may change the aspect ratio of the object
10470
10471
  heightOnly - gets or sets the height. This sets only the height and may change the aspect ratio of the object
10472
+ cacheScale - get the requested scale parameter or if cached, the cache scale
10471
10473
  draggable - set to true for a default drag() and false for a noDrag()
10472
10474
  level - gets or sets the level of the object in its parent container (or the stage) - a property for parent.getChildIndex() and parent.setChildIndex()
10473
10475
  depth - for ZIM VR - the depth used to shift left and right channel and for parallax in VR - also see dep() ZIM Display method
@@ -10520,7 +10522,9 @@ zim.Bitmap = function(image, width, height, left, top, scale, style, group, inhe
10520
10522
 
10521
10523
  var that = this;
10522
10524
  this.type = "Bitmap";
10523
- if (!zot(width) && !zot(height)) this.setBounds(0,0,width,height);
10525
+ if (!zot(width) && !zot(height)) this.setBounds(0,0,width*scale,height*scale);
10526
+
10527
+ this.cacheScale = scale;
10524
10528
 
10525
10529
  this.drawImageData = function(x, y, sourceX, sourceY, sourceWidth, sourceHeight) {
10526
10530
  if (zot(x)) x = 0;
@@ -10607,6 +10611,7 @@ zim.Bitmap = function(image, width, height, left, top, scale, style, group, inhe
10607
10611
  var sig = "a,b,c,d,scale,options,rtl,willReadFrequently";
10608
10612
  var duo; if (duo = zob(that.cache, arguments, sig)) return duo;
10609
10613
  var bounds;
10614
+ that.cacheScale = scale;
10610
10615
  if (zot(c)) {
10611
10616
  if (zot(a)) {
10612
10617
  bounds = this.getBounds();
@@ -27138,7 +27143,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
27138
27143
  });
27139
27144
  var titleBarLabel = that.titleBarLabel = t;
27140
27145
  if (zot(tBarBackgroundColor)) tBarBackgroundColor = "rgba(0,0,0,.2)";
27141
- that.titleBar = titleBar = new zim.Container(width, titleBarHeight, null, null, false).loc(0,0,that);
27146
+ that.titleBar = titleBar = new zim.Container(width, titleBarHeight, null, null, false).loc(0,-borderWidth/2,that);
27142
27147
  var titleBarRect = that.titleBar.backing = new zim.Rectangle(width+borderWidth, titleBarHeight, tBarBackgroundColor, null, null, [corner[0]*.95, corner[1]*.95, 0, 0], true, null, null, false).center(titleBar);
27143
27148
  if (titleBar) positionBar();
27144
27149
  that.label = t;
@@ -30810,7 +30815,7 @@ zim.TextInput = function(width, height, placeholder, text, size, font, color, ba
30810
30815
  that.stage.update();
30811
30816
  }
30812
30817
  }
30813
- if (placeholderInstant && that.placeholderLabel.parent) {
30818
+ if (placeholderInstant && that.placeholderLabel.parent) {
30814
30819
  that.placeholderLabel.removeFrom();
30815
30820
  if (that.stage) that.stage.update();
30816
30821
  }
@@ -31235,7 +31240,7 @@ zim.TextInput.LabelInput = function(text, size, maxLength, password, selectionCo
31235
31240
  var paddingH = this.backing || this.background ? this.paddingH : 0;
31236
31241
  var paddingV = this.backing || this.background ? this.paddingV : 0;
31237
31242
 
31238
- if (this.hiddenInput.selectionStart !== this.hiddenInput.selectionEnd) {
31243
+ if (this.hiddenInput.selectionStart !== this.hiddenInput.selectionEnd || le == 0) {
31239
31244
  var startX, endX;
31240
31245
  if (rtl) {
31241
31246
  startX = this.textWidthArray[le-this.hiddenInput.selectionStart]
@@ -31255,8 +31260,10 @@ zim.TextInput.LabelInput = function(text, size, maxLength, password, selectionCo
31255
31260
  }
31256
31261
  this.blinker.heightOnly = this.textHeight;
31257
31262
  var xIdx = this.hiddenInput.selectionDirection === "backward" ? this.hiddenInput.selectionStart : this.hiddenInput.selectionEnd;
31258
- if (!xIdx) xIdx = 0; // ZIM NFT 00 Patch
31263
+ // if (!xIdx) xIdx = 0; // ZIM NFT 00 Patch
31264
+ if (xIdx==null) xIdx = le; // ZIM 017 Patch
31259
31265
  if (rtl) xIdx = le-xIdx;
31266
+
31260
31267
  this.blinker.pos(this.textWidthArray[xIdx] + paddingH - 1 + ((align=="right" && this.text == "")?this.width:(align=="center" && this.text == "")?this.width/2:0) + shiftH, paddingV+shiftV);
31261
31268
  this.dispatchEvent("blinker");
31262
31269
  }
@@ -32985,6 +32992,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
32985
32992
  target.zgb = target.boundsToGlobal();
32986
32993
  target.zgs = target.getConcatenatedDisplayProps().matrix.decompose().scaleX/frame.stage.scaleX;
32987
32994
  });
32995
+ return that;
32988
32996
  }
32989
32997
 
32990
32998
  Object.defineProperty(that, 'dropTargets', {
@@ -34523,7 +34531,7 @@ expandBarVertical - (default 0 or 20 for horizontal) set to value to expand the
34523
34531
  useLabels - (default false) - add Labels to ticks if useTicks is true - can apply STYLE
34524
34532
  labelMargin - (default 20) - distance from ticks to Label if useLabels is true
34525
34533
  labelColor - (default 20) - distance from ticks to Label if useLabels is true
34526
- range - (default null) make the slider a range slider with two circle buttons
34534
+ range - (default false) set to true to change to a range slider with two circle buttons
34527
34535
  this will provide read and write rangeMin, rangeMax and rangeAve values instead of value
34528
34536
  also will provide a read only rangeAmount
34529
34537
  rangeBar, rangeSliderA, rangeSliderB, rangeButtonA and rangeButtonB properties will be added
@@ -59713,7 +59721,7 @@ transition - (default "none") the type of transition "none", "reveal", "slide",
59713
59721
  NOTE: if using pages that are smaller than the stage, use a Rectangle() as the holder
59714
59722
  and the transition effects will be automatically masked by the rectangle.
59715
59723
  speed - (default .2) speed in seconds of the transition if set (see also ZIM TIME constant)
59716
- transitionTable - (default none) an array to override general transitions with following format:
59724
+ transitionTable - (default "none") an array to override general transitions with following format:
59717
59725
  [[fromPage, toPage, "transition", seconds(optional)], etc.]
59718
59726
  holder - (default the default stage) where are we putting the pages (used for setting transition properties)
59719
59727
  If using pages that are smaller than the stage
@@ -60512,6 +60520,7 @@ Additional "mousedown", "click" or other button events can be added if desired
60512
60520
  this.group = group;
60513
60521
  var DS = style===false?{}:zim.getStyle("Arrow", this.group, inherit);
60514
60522
 
60523
+ if (zot(pages)) pages = DS.pages!=null?DS.pages:null;
60515
60524
  if (zot(direction)) direction = DS.direction!=null?DS.direction:"right";
60516
60525
  if (zot(backgroundColor)) backgroundColor = DS.backgroundColor!=null?DS.backgroundColor:zim.blue;
60517
60526
  this.arrowBackgroundColor = backgroundColor;
@@ -62850,8 +62859,8 @@ note: the item is not the event object target - as that is the tile
62850
62859
  if (!zot(width)) colSize = null; // width and height override sizes
62851
62860
  if (!zot(height)) rowSize = null;
62852
62861
 
62853
- if (zot(spacingH)) spacingH = DS.spacingH!=null?DS.spacingH:defaultFlag?3:null;
62854
- if (zot(spacingV)) spacingV = DS.spacingV!=null?DS.spacingV:defaultFlag?3:null;
62862
+ if (zot(spacingH)) spacingH = DS.spacingH!=null?DS.spacingH:null;
62863
+ if (zot(spacingV)) spacingV = DS.spacingV!=null?DS.spacingV:null;
62855
62864
  var spacingHO = spacingH;
62856
62865
  var spacingVO = spacingV;
62857
62866
  if (zot(spacingH) || !zot(colSize) || !zot(width)) spacingH = 0; // sizes override spacing
@@ -70718,7 +70727,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
70718
70727
  if (target.type == "Pen") target.write = false;
70719
70728
  mouseEvent = stage.on("stagemousedown", function(e) {
70720
70729
  var pp;
70721
- // if (target.type == "Pen" || type == "pressmove") {
70730
+ if (target.type == "Pen" && target.draggingCheck) zogb();
70722
70731
  var con;
70723
70732
  if (!mouseOutside && that.boundary && !that.boundary.type=="Blob") con = that.boundary;
70724
70733
  else if (!mouseOutside && container && container.boundsToGlobal) con = container.boundsToGlobal();
@@ -70873,7 +70882,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
70873
70882
  function moveMe() {
70874
70883
  var p = container.globalToLocal(that.moveX, that.moveY);
70875
70884
  that.x = p.x; that.y = p.y;
70876
- calculate();
70885
+ calculate();
70877
70886
  if (target.type == "Pen" && !moveCheck && target.drawing) moveCheck = true;
70878
70887
  }
70879
70888
 
@@ -70957,6 +70966,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
70957
70966
  var lastDirY=0;
70958
70967
 
70959
70968
  var mainTicker = zim.Ticker.add(function() {
70969
+ if (target.draggingCheck) return;
70960
70970
  if (type == "manual") calculate();
70961
70971
  if (that.boundary && that.boundary.type!="Blob") {
70962
70972
  that.x = zim.constrain(that.x, that.boundary.x, that.boundary.x+that.boundary.width);
@@ -78981,6 +78991,49 @@ pen.animate({
78981
78991
  })
78982
78992
  END EXAMPLE
78983
78993
 
78994
+ EXAMPLE
78995
+ // A Pen used on two different Pages with ZIM Pages
78996
+ // See https://zimjs.com/zapp/Z_VKB33
78997
+
78998
+ const page1 = new Page(W,H,orange,red);
78999
+ page1.paper = new Container(W,H).addTo(page1);
79000
+ const page2 = new Page(W,H,pink,purple);
79001
+ page2.paper = new Container(W,H).addTo(page2);
79002
+
79003
+ const pages = new Pages([page1, page2]).addTo();
79004
+ pages.active = false; // so drawing does not accidentally swipe pages
79005
+
79006
+ STYLE = {
79007
+ Arrow: {
79008
+ type:"angle",
79009
+ pages:pages,
79010
+ direction:series(RIGHT, LEFT),
79011
+ trans:"fan",
79012
+ rotation:series(0,180)
79013
+ }
79014
+ }
79015
+ const next = new Arrow().pos(50,50,RIGHT,BOTTOM);
79016
+ const prev = new Arrow().pos(50,50,LEFT,BOTTOM);
79017
+
79018
+ const pen = new Pen({
79019
+ paper:page1.paper,
79020
+ size:20,
79021
+ color:series(white,black)
79022
+ }).addTo();
79023
+
79024
+ // switch papers
79025
+ pages.on("page", ()=>{
79026
+ pen.paper = pages.page.paper;
79027
+ });
79028
+
79029
+ new MotionController({
79030
+ target:pen,
79031
+ type:"pressmove",
79032
+ speed:40,
79033
+ mousedownIncludes:[pages] // so will track mouse on pages
79034
+ });
79035
+ END EXAMPLE
79036
+
78984
79037
  PARAMETERS
78985
79038
  ** supports DUO - parameters or single object with properties below
78986
79039
  ** supports VEE - parameters marked with ZIM VEE mean a zim Pick() object or Pick Literal can be passed
@@ -79041,12 +79094,8 @@ saveState(obj, startLayer, endLayer) - record an undo state for the paper or a l
79041
79094
  startLayer and endLayer are for if the layer level of the shape changes
79042
79095
  undo() - go back one undo state (called automatically by CTRL Z if undoKeys is true - default)
79043
79096
  redo() - go forward one undo state (called automatically by CTRL Y or CTRL SHIFT Z if undoKeys is true - default)
79044
- delete(index) - delete a line segment at a given index (actually sets its alpha to 0 to maintain layers on undo)
79045
- use: pen.paper.on("mousedown", function (e) {
79046
- pen.delete(paper.getChildIndex(e.target)); // for instance
79047
- })
79048
79097
  deleteSegment(object) - delete a line segment object
79049
- use: pen.paper.on("mousedown", function (e) {
79098
+ use: pen.paper.on("mousedown", e => {
79050
79099
  pen.deleteSegment(e.target); // for instance
79051
79100
  })
79052
79101
  clone() - clone the pen (note there is no exact clone)
@@ -79709,6 +79758,7 @@ dispatches an "undo" and a "redo" whenever undo and redo happens
79709
79758
  });
79710
79759
  paper.drag({onTop:onTop});
79711
79760
  paper.on("pressup", function (e) {
79761
+ that.draggingCheck = false;
79712
79762
  if (deleteable && that.shiftKey) return;
79713
79763
  // if (e.target.alpha == 0) return;
79714
79764
  if (e.target.visible == false) return;
@@ -82523,6 +82573,18 @@ EXAMPLE
82523
82573
  new Pane({content:"START", keyboardAccess:true}).show();
82524
82574
  END EXAMPLE
82525
82575
 
82576
+ EXAMPLE
82577
+ // dynamically adjusting touch - there are also touch and singleTouch parameters of Frame
82578
+ // also, drag() has its own singleTouch parameter
82579
+ const radio = new RadioButtons(30, ["MULTI TOUCH", "SINGLE TOUCH", "NO TOUCH"]).center().mov(0,-200).change(()=>{
82580
+ if (radio.text.includes("MULTI")) F.singleTouch = false;
82581
+ else if (radio.text.includes("SINGLE")) F.singleTouch = true;
82582
+ else F.touch = false;
82583
+ });
82584
+ new Circle(50,white,red,5).center().mov(-100,50).drag();
82585
+ new Circle(50,white,purple,5).center().mov(100,50).drag();
82586
+ END EXAMPLE
82587
+
82526
82588
  PARAMETERS supports DUO - parameters or single object with properties below
82527
82589
  scaling - (default FULL) can have values as follows
82528
82590
  Note: as of ZIM Cat 04, the constant FIT or the string "fit", etc. can be used
@@ -82571,7 +82633,9 @@ ticker - (default null) - an optional callback function to be added to the ZIM T
82571
82633
  progress - (default null) - set to a Waiter() or ProgressBar() object to show while loading
82572
82634
  rollover - (default true or false on mobile) activates rollovers
82573
82635
  touch - (default true) activates touch on mobile - this will be multitouch by default
82574
- set to false for no touch on mobile - also see singleTouch parameter to set singleTouch
82636
+ set to false for no touch on mobile
82637
+ also see singleTouch parameter to set singleTouch
82638
+ also see touch and singleTouch properties
82575
82639
  scrollTop - (default false) activates scrolling on older apple devices to hide the url bar
82576
82640
  align - (default CENTER) for FIT and FILL, the horizontal alignment LEFT, CENTER, RIGHT
82577
82641
  valign - (default CENTER) for FIT and FILL, the vertical alignment TOP, CENTER, BOTTOM
@@ -82620,6 +82684,7 @@ maxNum - for sound this is how many instances of the sound can play at once
82620
82684
  also see sound interrupt parameter
82621
82685
  singleTouch - set to true for single touch rather than the default multitouch (or touch false)
82622
82686
  this will override the touch setting to turn touch to true
82687
+ also see touch and singleTouch properties
82623
82688
 
82624
82689
  METHODS
82625
82690
  loadAssets(assets, path, progress, xhr, time, loadTimeout, outputAudioSprite, crossOrigin, fileType, queueOnly, maxConnections, maxNum) |ZIM DUO| also accepts ZIM DUO configuration object as single parameter
@@ -82903,6 +82968,11 @@ zil - reference to zil events that stop canvas from shifting or scrolling - also
82903
82968
  can set allowDefault property to false then allow specific defaults by removing zil events - see zil global function
82904
82969
  example: window.removeEventListener("keydown", F.zil[0]); removes keydown preventions (for page up, page down, home, end, etc)
82905
82970
  allowDefault - set to true to remove zil or false to set zil (see above) also affects body overflow
82971
+ touch - get or set the touch setting - setting to false will not allow touch on mobile
82972
+ also see touch and singleTouch parameters and singleTouch property
82973
+ singleTouch - get or set the singleTouch setting - set to true to turn on single touch and false to turn on multitouch
82974
+ setting either true or false will set the touch property to true
82975
+ also see the touch and singleTouch parameters and touch property
82906
82976
  followBoundary - update with a ZIM Boundary for follow() if "full" mode Frame "resize" event happens, etc.
82907
82977
  altKey - true if the alt key is being pressed otherwise false
82908
82978
  ctrlKey - true if the ctrl key is being pressed otherwise false
@@ -84478,6 +84548,31 @@ zim.Frame = function(scaling, width, height, color, outerColor, ready, assets, p
84478
84548
  }
84479
84549
  });
84480
84550
 
84551
+ Object.defineProperty(that, 'touch', {
84552
+ get: function() {
84553
+ return touch;
84554
+ },
84555
+ set: function(value) {
84556
+ touch = value;
84557
+ createjs.Touch.disable(that.stage);
84558
+ if (touch) {
84559
+ createjs.Touch.enable(that.stage, singleTouch); // true for single touch, false for multitouch
84560
+ }
84561
+ }
84562
+ });
84563
+
84564
+ Object.defineProperty(that, 'singleTouch', {
84565
+ get: function() {
84566
+ return singleTouch;
84567
+ },
84568
+ set: function(value) {
84569
+ singleTouch = value;
84570
+ touch = true;
84571
+ createjs.Touch.disable(that.stage);
84572
+ createjs.Touch.enable(that.stage, singleTouch); // true for single touch, false for multitouch
84573
+ }
84574
+ });
84575
+
84481
84576
 
84482
84577
  // CURSOR SYSTEM WITH CUR()
84483
84578
  // added ZIM 014
@@ -89312,7 +89407,7 @@ but usually, just pass the callback as the first parameter
89312
89407
  tile.center(pane);
89313
89408
  }
89314
89409
 
89315
- if (M && !( WW.matchMedia('(display-mode: standalone)').matches || (WW.navigator.standalone) || document.referrer.includes('android-app://') )) {
89410
+ if (M && !( WW.matchMedia('(display-mode: fullscreen)').matches || WW.matchMedia('(display-mode: standalone)').matches || (WW.navigator.fullscreen) || (WW.navigator.standalone) || document.referrer.includes('android-app://') )) {
89316
89411
  showMessage();
89317
89412
  } else {
89318
89413
  if (call && call.constructor === Function) call();
@@ -34,6 +34,7 @@ declare global {
34
34
  var yellow: string
35
35
  var purple: string
36
36
  var red: string
37
+ var salmon: string
37
38
  var interstellar: string
38
39
  var black: string
39
40
  var darker: string
@@ -1387,6 +1388,7 @@ declare namespace zim {
1387
1388
  height: number
1388
1389
  widthOnly: number
1389
1390
  heightOnly: number
1391
+ cacheScale: number
1390
1392
  marginLeft: number
1391
1393
  marginRight: number
1392
1394
  marginTop: number
@@ -3772,28 +3774,12 @@ declare namespace zim {
3772
3774
  visibleRight: number
3773
3775
  visibleBottom: number
3774
3776
  cursors: {}
3777
+ allowDefault: boolean
3778
+ touch: boolean
3779
+ singleTouch: boolean
3775
3780
  readonly cursorList: Dictionary
3776
3781
  readonly cursorObj: DisplayObject
3777
3782
  zil: Function[]
3778
- readonly orange: string
3779
- readonly green: string
3780
- readonly pink: string
3781
- readonly blue: string
3782
- readonly brown: string
3783
- readonly yellow: string
3784
- readonly red: string
3785
- readonly purple: string
3786
- readonly silver: string
3787
- readonly tin: string
3788
- readonly grey: string
3789
- readonly lighter: string
3790
- readonly light: string
3791
- readonly dark: string
3792
- readonly darker: string
3793
- readonly white: string
3794
- readonly black: string
3795
- readonly clear: string
3796
- readonly faint: string
3797
3783
  altKey: boolean
3798
3784
  ctrlKey: boolean
3799
3785
  metaKey: boolean