zimjs 18.1.7 → 18.1.9

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": "18.1.7",
3
+ "version": "18.1.9",
4
4
  "type": "module",
5
5
  "main": "./src/zim.js",
6
6
  "types": "./ts-src/typings/zim",
package/src/zim.js CHANGED
@@ -31324,6 +31324,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31324
31324
  group:this.group
31325
31325
  });
31326
31326
  if (!zot(percentage) && zot(label)) label = new zim.Label("");
31327
+ if (zot(percentage)) percentage=DS.percentage!=null?DS.percentage:false;
31327
31328
  this.label = label;
31328
31329
 
31329
31330
  var height = 30;
@@ -31388,7 +31389,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31388
31389
  if (!zot(label)) {
31389
31390
  label.scaleX = label.scaleY = .8;
31390
31391
  label.startText = label.text;
31391
- if (!zot(percentage)) label.text = label.startText + " 0%";
31392
+ if (percentage) label.text = label.startText + " 0%";
31392
31393
  label.center(that);
31393
31394
  if (labelPosition == "above") {
31394
31395
  label.y -= 60;
@@ -31496,7 +31497,7 @@ added, click, dblclick, mousedown, mouseout, mouseover, pressdown (ZIM), pressmo
31496
31497
  mask.sca(amount/100, 1);
31497
31498
  bar.setMask(mask);
31498
31499
  }
31499
- if (!zot(percentage)) label.text = label.startText + " " + Math.min(Math.round(amount), 100) + "%";
31500
+ if (percentage) label.text = label.startText + " " + Math.min(Math.round(amount), 100) + "%";
31500
31501
  if (autoHide && fastClose && Math.round(amount) >= 100) that.timeOut = setTimeout(function(){that.hide();}, 200);
31501
31502
  if (!that.dispatched && Math.round(amount) >= 100) {
31502
31503
  that.dispatchEvent("complete");
@@ -47748,6 +47749,8 @@ zim.Carousel3D = function(width, height, items, widthFactor, heightFactor, curve
47748
47749
 
47749
47750
  var shift;
47750
47751
  var min, max;
47752
+
47753
+
47751
47754
 
47752
47755
  this.makeCarousel = function() {
47753
47756
 
@@ -47810,7 +47813,7 @@ zim.Carousel3D = function(width, height, items, widthFactor, heightFactor, curve
47810
47813
  that.holder.loop(function(item, i) {
47811
47814
  item.y = item.start - r + (that.amount+r+r*2*1000000 + item.shift) % (r*2);
47812
47815
  var delta = item.y - center;
47813
- var w = Math.sqrt(Math.pow(r,2) - Math.pow(delta,2)) * 2;
47816
+ var w = (Math.sqrt(Math.pow(r,2) - Math.pow(delta,2)) * 2) || 0;
47814
47817
  item.width = w;
47815
47818
  var sh = zim.sign((height/2-item.y)) * Math.round(Math.pow((height/2-item.y), 2)/(10+900*(1-that.curve)));
47816
47819
  item.mov(0,delta*heightFactor+sh);
@@ -47823,12 +47826,12 @@ zim.Carousel3D = function(width, height, items, widthFactor, heightFactor, curve
47823
47826
  that.holder.loop(function(item, i) {
47824
47827
  item.x = item.start - r + (that.amount+r+r*2*1000000 + item.shift) % (r*2);
47825
47828
  var delta = item.x - center;
47826
- var h = Math.sqrt(Math.pow(r,2) - Math.pow(delta,2)) * 2;
47827
- item.height = h;
47829
+ var h = (Math.sqrt(Math.pow(r,2) - Math.pow(delta,2)) * 2) || 0;
47830
+ item.height = h;
47828
47831
  var sh = zim.sign((width/2-item.x)) * Math.round(Math.pow((width/2-item.x), 2)/(10+900*(1-that.curve)));
47829
- item.mov(delta*widthFactor+sh);
47832
+ item.mov(delta*widthFactor+sh);
47830
47833
  item.height = constrain(item.height - (height-item.height)*heightFactor,0,100000);
47831
- item.visible = item.height>0;
47834
+ item.visible = item.height>0;
47832
47835
  });
47833
47836
  that.holder.sortBy("height");
47834
47837
  }
@@ -47836,7 +47839,7 @@ zim.Carousel3D = function(width, height, items, widthFactor, heightFactor, curve
47836
47839
  var index = that.currentItem.dexIndex;
47837
47840
  if (index != that.latestIndex) {
47838
47841
  that.holder.loop(function(item,i,t) {
47839
- if (interactive) {
47842
+ if (interactive) {
47840
47843
  if (item==that.currentItem) {
47841
47844
  item.mouseEnabled = true;
47842
47845
  item.mouseChildren = true;
@@ -74072,7 +74075,7 @@ dispatches a "swipestop" event when swipeup has happened and value has stopped c
74072
74075
  //-69.5
74073
74076
 
74074
74077
  /*--
74075
- zim.MotionController = function(target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown)
74078
+ zim.MotionController = function(target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown, offTime)
74076
74079
 
74077
74080
  MotionController
74078
74081
  zim class - extends a createjs EventDispatcher
@@ -74113,6 +74116,18 @@ new MotionController({
74113
74116
  });
74114
74117
  END EXAMPLE
74115
74118
 
74119
+ EXAMPLE
74120
+ // good setting for motion following cursor
74121
+ // on mousedown or finger dragging on mobile
74122
+ const t = new Triangle(80,100,100).rot(90).center();
74123
+ const mc = new MotionController({
74124
+ target:t,
74125
+ type:"follow",
74126
+ orient:true,
74127
+ offTime:.25
74128
+ });
74129
+ END EXAMPLE
74130
+
74116
74131
  EXAMPLE
74117
74132
  F.loadAssets(["beach02.jpg", "playbeachball.png"], "https://zimjs.org/assets/"); // or load in Frame()
74118
74133
  F.on("complete", ()=>{
@@ -74153,6 +74168,9 @@ target (default null) - the object you want to control
74153
74168
  if you only want data from the MotionController you can leave the target parameter as null (don't include it)
74154
74169
  can be a Pen() - both pen and motionController have damp parameter so probably adjust one or the other to 1
74155
74170
  type - (default "mousedown") by default will move to where you press in the container
74171
+ see upTime parameter to stop moving when mouse is up
74172
+ set to "follow" to mousedown and hold to keep moving towards mouse or press position - can also use F.follow() to move stage as well
74173
+ see upTime parameter to stop moving when mouse is up
74156
74174
  set to "mousemove" to have the target follow the mouse movement
74157
74175
  set to "pressmove" to have target jump to mousedown position then follow while pressing - good for Pen
74158
74176
  set to "pressdrag" to have target follow mouse if pressed on and then dragged (dedicated to Shan Ruan)
@@ -74160,7 +74178,6 @@ type - (default "mousedown") by default will move to where you press in the cont
74160
74178
  set to "gamebutton" to use gamepad buttons to control the target (see map parameter)
74161
74179
  set to "gamestick" to use gamepad stick(s) to control the target (see map parameter)
74162
74180
  set to "swipe" to use swipe to control the target
74163
- set to "follow" to mousedown and hold and use F.follow() to keep moving towards mouse or press position
74164
74181
  set to "manual" to set your own with myController.convert() or myController.x and myController.y properties
74165
74182
  set to a ZIM DPad object to use the DPad to control the motion
74166
74183
  speed - (default 7 or 20 if type is pressmove) pixels it will move each tick, keypress buttonpress, swipe, etc.
@@ -74243,6 +74260,10 @@ tileObj - (default null) an object to direct the target to move on a theoretical
74243
74260
  note: this will override the cols and rows values
74244
74261
  penDown - (default null) set to true with Pen to make MotionControler draw the Pen on mousedown so a dot can be drawn
74245
74262
  otherwise the dot is drawn on mouseup if the pen has not moved more than 2 pixels
74263
+ offTime - (default null) set to a time (including 0) to slow movement when mouse or press is up
74264
+ normally a mousedown or mousemove, etc. will move the target to the last mouse position
74265
+ but sometimes it is desired to have the movement stop when the mouse or press is up
74266
+ set a time here to allow the movement to slow to a stop on mouse or press up
74246
74267
 
74247
74268
  METHODS
74248
74269
  pause(state, time) - state defaults to true and pauses the motionController (sets speed to 0)
@@ -74292,8 +74313,8 @@ dispatches a "mousedown" event if type is "mousedown" or "pressmove"
74292
74313
  dispatches a "pressing" event if type is "pressmove" - note, this dispatches even if not moving
74293
74314
  dispatches a "moving" event if target is moving and "startmoving" and "stopmoving" events
74294
74315
  --*///+69.7
74295
- zim.MotionController = function(target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown) {
74296
- var sig = "target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown";
74316
+ zim.MotionController = function(target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown, offTime) {
74317
+ var sig = "target, type, speed, axis, boundary, map, diagonal, damp, flip, orient, constant, firstPerson, turnSpeed, moveThreshold, stickThreshold, container, localBoundary, mouseMoveOutside, mousedownIncludes, minPercentSpeed, maxPercentSpeed, dampKeyup, rotate, mouseOutside, tileObj, penDown, offTime";
74297
74318
  var duo; if (duo = zob(zim.MotionController, arguments, sig, this)) return duo;
74298
74319
  z_d("69.7");
74299
74320
 
@@ -74465,6 +74486,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74465
74486
  var mouseEvent2;
74466
74487
  var mouseEvent3;
74467
74488
  var mouseEvent4;
74489
+ var offTimeEvent;
74468
74490
  var pressing = false;
74469
74491
  var moveCheck = false;
74470
74492
  var under, i, a, gamepad, first;
@@ -74523,7 +74545,13 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74523
74545
  calculate();
74524
74546
  }, stage);
74525
74547
  } else if (type == "mousedown" || type == "mousemove") {
74526
- mouseEvent = stage.on("stage" + type, function(e){
74548
+ mouseEvent = stage.on("stage" + type, function(e){
74549
+ if (that.offSpeed) {
74550
+ that.stopAnimate("off");
74551
+ that.paused = false;
74552
+ that.speed = that.offSpeed;
74553
+ that.offSpeed = null;
74554
+ }
74527
74555
  stage = e.target.stage;
74528
74556
  var pp;
74529
74557
  var con;
@@ -74550,7 +74578,14 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74550
74578
  that.x = p.x; that.y = p.y;
74551
74579
  calculate();
74552
74580
  });
74581
+ if (!zot(offTime)) offTimeEvent = stage.on("stagemouseup", doOffTime);
74553
74582
  } else if (type == "pressmove" || type == "pressdrag" || type == "follow") {
74583
+ if (that.offSpeed) {
74584
+ that.stopAnimate("off");
74585
+ that.paused = false;
74586
+ that.speed = that.offSpeed;
74587
+ that.offSpeed = null;
74588
+ }
74554
74589
  if (target.type == "Pen") target.write = false;
74555
74590
  mouseEvent = stage.on("stagemousedown", function(e) {
74556
74591
  var pp;
@@ -74637,6 +74672,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74637
74672
  stage.off("stagemousemove", mouseEvent2);
74638
74673
  pressing = false;
74639
74674
  });
74675
+ if (!zot(offTime)) offTimeEvent = stage.on("stagemouseup", doOffTime)
74640
74676
 
74641
74677
  } else if (type == "gamestick") {
74642
74678
  gamepad = this.gamepad = new zim.GamePad();
@@ -74695,6 +74731,20 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74695
74731
  });
74696
74732
  }
74697
74733
 
74734
+ var offCheck = false;
74735
+ function doOffTime() {
74736
+ if (offCheck) return;
74737
+ offCheck = true;
74738
+ if (that.paused || !that.enabled) return;
74739
+ that.offSpeed = that.speed;
74740
+ zim.animate({target:that, obj:{pausingSpeed:0}, ticker:false, id:"off", time:offTime, call:function() {
74741
+ that.immediate(that.target.x, that.target.y);
74742
+ that.speed = that.offSpeed;
74743
+ that.offSpeed = null;
74744
+ that.paused = false;
74745
+ offCheck = false;
74746
+ }});
74747
+ }
74698
74748
 
74699
74749
  function doDown(e) {
74700
74750
  wasDown = true;
@@ -75131,11 +75181,11 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
75131
75181
  that.enabled = true;
75132
75182
  if (time > 0) {
75133
75183
  zim.animate({target:that, obj:{pausingSpeed:lastSpeed}, ticker:false, time:time, call:function() {
75134
- that.speed = lastSpeed;
75184
+ if (lastSpeed) that.speed = lastSpeed;
75135
75185
  that.paused = false;
75136
75186
  }});
75137
- } else {
75138
- that.speed = lastSpeed;
75187
+ } else {
75188
+ if (lastSpeed) that.speed = lastSpeed;
75139
75189
  that.paused = false;
75140
75190
  }
75141
75191
  }
@@ -75177,10 +75227,12 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
75177
75227
  if (swiperEvent) swiperEvent = swiperX.on("swipemove", swiperEvent);
75178
75228
  } else if (type == "mousedown" || type == "mousemove") {
75179
75229
  mouseEvent = stage.on("stage" + type, mouseEvent);
75230
+ if (offTimeEvent) offTimeEvent = stage.on("stagemouseup", offTimeEvent);
75180
75231
  } else if (type == "pressmove") {
75181
75232
  mouseEvent = stage.on("stagemousedown", mouseEvent);
75182
75233
  if (mouseEvent2) mouseEvent2 = stage.on("stagemousemove", mouseEvent2);
75183
75234
  if (mouseEvent3) mouseEvent3 = stage.on("stagemouseup", mouseEvent3);
75235
+ if (offTimeEvent) offTimeEvent = stage.on("stagemouseup", offTimeEvent);
75184
75236
  }
75185
75237
  mainTicker = zim.Ticker.add(mainTicker, stage);
75186
75238
  }
@@ -75201,10 +75253,12 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
75201
75253
  swiperX.off("swipemove", swiperEvent);
75202
75254
  } else if (type == "mousedown" || type == "mousemove") {
75203
75255
  stage.off("stage" + type, mouseEvent);
75256
+ stage.off("stagemouseup", offTimeEvent);
75204
75257
  } else if (type == "pressmove") {
75205
75258
  stage.off("stagemousedown", mouseEvent);
75206
75259
  stage.off("stagemousemove", mouseEvent2);
75207
75260
  stage.off("stagemouseup", mouseEvent3);
75261
+ stage.off("stagemouseup", offTimeEvent);
75208
75262
  }
75209
75263
  zim.Ticker.remove(mainTicker);
75210
75264
  }
@@ -98406,4 +98460,4 @@ export let Ticker = zim.Ticker;
98406
98460
  export let Style = zim.Style;
98407
98461
  export let assets = zim.assets;
98408
98462
  export let assetIDs = zim.assetIDs;
98409
- export let ZIMON = zim.ZIMON;
98463
+ export let ZIMON = zim.ZIMON;
@@ -3561,8 +3561,8 @@ declare namespace zim {
3561
3561
  enabled: boolean
3562
3562
  }
3563
3563
  export class MotionController extends createjs.EventDispatcher {
3564
- constructor(config_or_target?: DisplayObject, type?: string, speed?: number, axis?: string, boundary?: Boundary | createjs.Rectangle | { x: number, y: number, width: number, height: number }, map?: [number | number[]], diagonal?: boolean, damp?: number, flip?: string, orient?: boolean, constant?: boolean, firstPerson?: boolean, turnSpeed?: number, moveThreshold?: number, stickThreshold?: number, container?: Stage | StageGL | Container, localBounds?: boolean, mouseMoveOutside?: boolean, mousedownIncludes?: DisplayObject[], minPercentSpeed?: number, maxPercentSpeed?: number, dampKeyup?: number, rotate?: boolean, mouseOutside?: boolean, penDown?: boolean)
3565
- constructor(config: { target?: DisplayObject, type?: string, speed?: number, axis?: string, boundary?: Boundary | createjs.Rectangle | { x: number, y: number, width: number, height: number }, map?: [number | number[]], diagonal?: boolean, damp?: number, flip?: string, orient?: boolean, constant?: boolean, firstPerson?: boolean, turnSpeed?: number, moveThreshold?: number, stickThreshold?: number, container?: Stage | StageGL | Container, localBounds?: boolean, mouseMoveOutside?: boolean, mousedownIncludes?: DisplayObject[], minPercentSpeed?: number, maxPercentSpeed?: number, dampKeyup?: number, rotate?: boolean, mouseOutside?: boolean, penDown?: boolean })
3564
+ constructor(config_or_target?: DisplayObject, type?: string, speed?: number, axis?: string, boundary?: Boundary | createjs.Rectangle | { x: number, y: number, width: number, height: number }, map?: [number | number[]], diagonal?: boolean, damp?: number, flip?: string, orient?: boolean, constant?: boolean, firstPerson?: boolean, turnSpeed?: number, moveThreshold?: number, stickThreshold?: number, container?: Stage | StageGL | Container, localBounds?: boolean, mouseMoveOutside?: boolean, mousedownIncludes?: DisplayObject[], minPercentSpeed?: number, maxPercentSpeed?: number, dampKeyup?: number, rotate?: boolean, mouseOutside?: boolean, penDown?: boolean, upTime?: number)
3565
+ constructor(config: { target?: DisplayObject, type?: string, speed?: number, axis?: string, boundary?: Boundary | createjs.Rectangle | { x: number, y: number, width: number, height: number }, map?: [number | number[]], diagonal?: boolean, damp?: number, flip?: string, orient?: boolean, constant?: boolean, firstPerson?: boolean, turnSpeed?: number, moveThreshold?: number, stickThreshold?: number, container?: Stage | StageGL | Container, localBounds?: boolean, mouseMoveOutside?: boolean, mousedownIncludes?: DisplayObject[], minPercentSpeed?: number, maxPercentSpeed?: number, dampKeyup?: number, rotate?: boolean, mouseOutside?: boolean, penDown?: boolean, upTime?: number })
3566
3566
  immediate(x: number, y: number): void
3567
3567
  convert(x: number, y: number): void
3568
3568
  pause(state?: boolean, time?: number): this