zimjs 18.1.6 → 18.1.8

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.6",
3
+ "version": "18.1.8",
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");
@@ -74072,7 +74073,7 @@ dispatches a "swipestop" event when swipeup has happened and value has stopped c
74072
74073
  //-69.5
74073
74074
 
74074
74075
  /*--
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)
74076
+ 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
74077
 
74077
74078
  MotionController
74078
74079
  zim class - extends a createjs EventDispatcher
@@ -74153,6 +74154,9 @@ target (default null) - the object you want to control
74153
74154
  if you only want data from the MotionController you can leave the target parameter as null (don't include it)
74154
74155
  can be a Pen() - both pen and motionController have damp parameter so probably adjust one or the other to 1
74155
74156
  type - (default "mousedown") by default will move to where you press in the container
74157
+ see upTime parameter to stop moving when mouse is up
74158
+ 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
74159
+ see upTime parameter to stop moving when mouse is up
74156
74160
  set to "mousemove" to have the target follow the mouse movement
74157
74161
  set to "pressmove" to have target jump to mousedown position then follow while pressing - good for Pen
74158
74162
  set to "pressdrag" to have target follow mouse if pressed on and then dragged (dedicated to Shan Ruan)
@@ -74160,7 +74164,6 @@ type - (default "mousedown") by default will move to where you press in the cont
74160
74164
  set to "gamebutton" to use gamepad buttons to control the target (see map parameter)
74161
74165
  set to "gamestick" to use gamepad stick(s) to control the target (see map parameter)
74162
74166
  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
74167
  set to "manual" to set your own with myController.convert() or myController.x and myController.y properties
74165
74168
  set to a ZIM DPad object to use the DPad to control the motion
74166
74169
  speed - (default 7 or 20 if type is pressmove) pixels it will move each tick, keypress buttonpress, swipe, etc.
@@ -74243,6 +74246,10 @@ tileObj - (default null) an object to direct the target to move on a theoretical
74243
74246
  note: this will override the cols and rows values
74244
74247
  penDown - (default null) set to true with Pen to make MotionControler draw the Pen on mousedown so a dot can be drawn
74245
74248
  otherwise the dot is drawn on mouseup if the pen has not moved more than 2 pixels
74249
+ offTime - (default null) set to a time (including 0) to slow movement when mouse or press is up
74250
+ normally a mousedown or mousemove, etc. will move the target to the last mouse position
74251
+ but sometimes it is desired to have the movement stop when the mouse or press is up
74252
+ set a time here to allow the movement to slow to a stop on mouse or press up
74246
74253
 
74247
74254
  METHODS
74248
74255
  pause(state, time) - state defaults to true and pauses the motionController (sets speed to 0)
@@ -74292,8 +74299,8 @@ dispatches a "mousedown" event if type is "mousedown" or "pressmove"
74292
74299
  dispatches a "pressing" event if type is "pressmove" - note, this dispatches even if not moving
74293
74300
  dispatches a "moving" event if target is moving and "startmoving" and "stopmoving" events
74294
74301
  --*///+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";
74302
+ 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) {
74303
+ 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
74304
  var duo; if (duo = zob(zim.MotionController, arguments, sig, this)) return duo;
74298
74305
  z_d("69.7");
74299
74306
 
@@ -74465,6 +74472,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74465
74472
  var mouseEvent2;
74466
74473
  var mouseEvent3;
74467
74474
  var mouseEvent4;
74475
+ var offTimeEvent;
74468
74476
  var pressing = false;
74469
74477
  var moveCheck = false;
74470
74478
  var under, i, a, gamepad, first;
@@ -74523,7 +74531,13 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74523
74531
  calculate();
74524
74532
  }, stage);
74525
74533
  } else if (type == "mousedown" || type == "mousemove") {
74526
- mouseEvent = stage.on("stage" + type, function(e){
74534
+ mouseEvent = stage.on("stage" + type, function(e){
74535
+ if (that.offSpeed) {
74536
+ that.stopAnimate("off");
74537
+ that.paused = false;
74538
+ that.speed = that.offSpeed;
74539
+ that.offSpeed = null;
74540
+ }
74527
74541
  stage = e.target.stage;
74528
74542
  var pp;
74529
74543
  var con;
@@ -74550,7 +74564,14 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74550
74564
  that.x = p.x; that.y = p.y;
74551
74565
  calculate();
74552
74566
  });
74567
+ if (!zot(offTime)) offTimeEvent = stage.on("stagemouseup", doOffTime);
74553
74568
  } else if (type == "pressmove" || type == "pressdrag" || type == "follow") {
74569
+ if (that.offSpeed) {
74570
+ that.stopAnimate("off");
74571
+ that.paused = false;
74572
+ that.speed = that.offSpeed;
74573
+ that.offSpeed = null;
74574
+ }
74554
74575
  if (target.type == "Pen") target.write = false;
74555
74576
  mouseEvent = stage.on("stagemousedown", function(e) {
74556
74577
  var pp;
@@ -74618,7 +74639,10 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74618
74639
  if (penDown) {
74619
74640
  target.x+=2
74620
74641
  target.write = false;
74621
- timeout(0, function() {target.write = true});
74642
+ timeout(0, function() {
74643
+ target.write = true;
74644
+ if (target.stage) target.stage.update();
74645
+ });
74622
74646
  }
74623
74647
  }
74624
74648
  });
@@ -74634,6 +74658,7 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74634
74658
  stage.off("stagemousemove", mouseEvent2);
74635
74659
  pressing = false;
74636
74660
  });
74661
+ if (!zot(offTime)) offTimeEvent = stage.on("stagemouseup", doOffTime)
74637
74662
 
74638
74663
  } else if (type == "gamestick") {
74639
74664
  gamepad = this.gamepad = new zim.GamePad();
@@ -74692,6 +74717,20 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
74692
74717
  });
74693
74718
  }
74694
74719
 
74720
+ var offCheck = false;
74721
+ function doOffTime() {
74722
+ if (offCheck) return;
74723
+ offCheck = true;
74724
+ if (that.paused || !that.enabled) return;
74725
+ that.offSpeed = that.speed;
74726
+ zim.animate({target:that, obj:{pausingSpeed:0}, ticker:false, id:"off", time:offTime, call:function() {
74727
+ that.immediate(that.target.x, that.target.y);
74728
+ that.speed = that.offSpeed;
74729
+ that.offSpeed = null;
74730
+ that.paused = false;
74731
+ offCheck = false;
74732
+ }});
74733
+ }
74695
74734
 
74696
74735
  function doDown(e) {
74697
74736
  wasDown = true;
@@ -75128,11 +75167,11 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
75128
75167
  that.enabled = true;
75129
75168
  if (time > 0) {
75130
75169
  zim.animate({target:that, obj:{pausingSpeed:lastSpeed}, ticker:false, time:time, call:function() {
75131
- that.speed = lastSpeed;
75170
+ if (lastSpeed) that.speed = lastSpeed;
75132
75171
  that.paused = false;
75133
75172
  }});
75134
- } else {
75135
- that.speed = lastSpeed;
75173
+ } else {
75174
+ if (lastSpeed) that.speed = lastSpeed;
75136
75175
  that.paused = false;
75137
75176
  }
75138
75177
  }
@@ -75174,10 +75213,12 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
75174
75213
  if (swiperEvent) swiperEvent = swiperX.on("swipemove", swiperEvent);
75175
75214
  } else if (type == "mousedown" || type == "mousemove") {
75176
75215
  mouseEvent = stage.on("stage" + type, mouseEvent);
75216
+ if (offTimeEvent) offTimeEvent = stage.on("stagemouseup", offTimeEvent);
75177
75217
  } else if (type == "pressmove") {
75178
75218
  mouseEvent = stage.on("stagemousedown", mouseEvent);
75179
75219
  if (mouseEvent2) mouseEvent2 = stage.on("stagemousemove", mouseEvent2);
75180
75220
  if (mouseEvent3) mouseEvent3 = stage.on("stagemouseup", mouseEvent3);
75221
+ if (offTimeEvent) offTimeEvent = stage.on("stagemouseup", offTimeEvent);
75181
75222
  }
75182
75223
  mainTicker = zim.Ticker.add(mainTicker, stage);
75183
75224
  }
@@ -75198,10 +75239,12 @@ dispatches a "moving" event if target is moving and "startmoving" and "stopmovin
75198
75239
  swiperX.off("swipemove", swiperEvent);
75199
75240
  } else if (type == "mousedown" || type == "mousemove") {
75200
75241
  stage.off("stage" + type, mouseEvent);
75242
+ stage.off("stagemouseup", offTimeEvent);
75201
75243
  } else if (type == "pressmove") {
75202
75244
  stage.off("stagemousedown", mouseEvent);
75203
75245
  stage.off("stagemousemove", mouseEvent2);
75204
75246
  stage.off("stagemouseup", mouseEvent3);
75247
+ stage.off("stagemouseup", offTimeEvent);
75205
75248
  }
75206
75249
  zim.Ticker.remove(mainTicker);
75207
75250
  }
@@ -80768,6 +80811,11 @@ If you have moved, scaled or rotated the Emitter or its container,
80768
80811
  then you will want to use var point = myEmitter.localToGlobal(particle.x, particle.y)
80769
80812
  and get point.x and point.y to find the location of the particle relative to the stage coordinates
80770
80813
 
80814
+ NOTE: the Emitter sets the stage snapToPixelEnabled to true if cache is true
80815
+ As of ZIM 018, when the emitter is done it sets it to false (default for ZIM Stage).
80816
+ We do not know when its value is set ss the property is a CreateJS property - unless we override
80817
+ but for now, if snapToPixelEnabled is desired to be true, set it to true after using the emitter.
80818
+
80771
80819
  PARTICLES CONTAINER
80772
80820
  By default, the Emitter will make a Container and place it beneath itself when added to the stage.
80773
80821
  by separating the particles from the emitter, it allows the emitter to be moved without all the particles moving
@@ -81074,7 +81122,6 @@ zim.Emitter = function(obj, width, height, interval, num, life, fade, shrink, wa
81074
81122
  var stage;
81075
81123
  zim.added(that, addedToStage);
81076
81124
  function addedToStage(s) {
81077
-
81078
81125
  that.emitterPaused = null; // will set back using that.startEmitterPaused
81079
81126
 
81080
81127
  that.on("added", function () {
@@ -81498,6 +81545,7 @@ zim.Emitter = function(obj, width, height, interval, num, life, fade, shrink, wa
81498
81545
  if (p.trace?p.getChildAt(0).endSpurt:p.endSpurt) {
81499
81546
  sendEvent("spurtfizzed", p);
81500
81547
  that.spurting = false;
81548
+ if (cache) stage.snapToPixelEnabled = false;
81501
81549
  }
81502
81550
  if (that.pool) {
81503
81551
  if (p.pooled == "end") {
@@ -81559,12 +81607,14 @@ zim.Emitter = function(obj, width, height, interval, num, life, fade, shrink, wa
81559
81607
  // that.removeFrom();
81560
81608
  if (that.parent) that.parent.removeChild(that);
81561
81609
  that.particles.removeFrom();
81610
+ if (cache) stage.snapToPixelEnabled = false;
81562
81611
  };
81563
81612
 
81564
81613
  this.spurting = false;
81565
81614
  this.spurt = function(num, time, restart) {
81566
81615
  var sig = "num, time, restart";
81567
81616
  var duo; if (duo = zob(that.spurt, arguments, sig)) return duo;
81617
+ if (cache) stage.snapToPixelEnabled = true;
81568
81618
  if (!zot(time)) {
81569
81619
  zim.timeout(zim.Pick.choose(time), function() {
81570
81620
  lastSpurt(that.currentParticle);
@@ -81612,6 +81662,7 @@ zim.Emitter = function(obj, width, height, interval, num, life, fade, shrink, wa
81612
81662
  }
81613
81663
  that.zimInterval.pause();
81614
81664
  that.emitterPaused = true;
81665
+ if (cache) stage.snapToPixelEnabled = false;
81615
81666
  } else { // unpausing
81616
81667
  if (!that.emitterPaused) return that;
81617
81668
  if (restart) {
@@ -81632,6 +81683,7 @@ zim.Emitter = function(obj, width, height, interval, num, life, fade, shrink, wa
81632
81683
  }
81633
81684
  if (that.zimInterval) that.zimInterval.pause(false, immediate);
81634
81685
  that.emitterPaused = false;
81686
+ if (cache) stage.snapToPixelEnabled = true;
81635
81687
  }
81636
81688
  return that;
81637
81689
  };
@@ -81661,6 +81713,7 @@ zim.Emitter = function(obj, width, height, interval, num, life, fade, shrink, wa
81661
81713
 
81662
81714
 
81663
81715
  this.dispose = function() {
81716
+ if (cache) stage.snapToPixelEnabled = true;
81664
81717
  if (that.zimInterval) that.zimInterval.clear();
81665
81718
  if (emitterTicker) {
81666
81719
  zim.Ticker.remove(emitterTicker);
@@ -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