pts 0.11.5 → 0.11.6

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/dist/index.d.ts CHANGED
@@ -22,6 +22,8 @@ declare const UIPointerActions: {
22
22
  click: string;
23
23
  keydown: string;
24
24
  keyup: string;
25
+ pointerdown: string;
26
+ pointerup: string;
25
27
  contextmenu: string;
26
28
  all: string;
27
29
  };
@@ -464,9 +466,11 @@ declare abstract class MultiTouchSpace extends Space {
464
466
  bindTouch(bind?: boolean, passive?: boolean, customTarget?: Element): this;
465
467
  bindKeyboard(bind?: boolean): this;
466
468
  touchesToPoints(evt: TouchEvent, which?: TouchPointsKey): Pt[];
467
- protected _mouseAction(type: string, evt: MouseEvent | TouchEvent): void;
469
+ protected _mouseAction(type: string, evt: MouseEvent | TouchEvent | PointerEvent): void;
468
470
  protected _mouseDown(evt: MouseEvent | TouchEvent): boolean;
471
+ protected _pointerDown(evt: PointerEvent): boolean;
469
472
  protected _mouseUp(evt: MouseEvent | TouchEvent): boolean;
473
+ protected _pointerUp(evt: PointerEvent): boolean;
470
474
  protected _mouseMove(evt: MouseEvent | TouchEvent): boolean;
471
475
  protected _mouseOver(evt: MouseEvent | TouchEvent): boolean;
472
476
  protected _mouseOut(evt: MouseEvent | TouchEvent): boolean;
package/dist/index.js CHANGED
@@ -4300,6 +4300,8 @@ var UIPointerActions = {
4300
4300
  click: "click",
4301
4301
  keydown: "keydown",
4302
4302
  keyup: "keyup",
4303
+ pointerdown: "pointerdown",
4304
+ pointerup: "pointerup",
4303
4305
  contextmenu: "contextmenu",
4304
4306
  all: "all"
4305
4307
  };
@@ -4775,7 +4777,7 @@ var Space = class {
4775
4777
  add(p) {
4776
4778
  let player = typeof p == "function" ? { animate: p } : p;
4777
4779
  let k = this.playerCount++;
4778
- let pid = this.id + k;
4780
+ let pid = player.animateID || this.id + k;
4779
4781
  this.players[pid] = player;
4780
4782
  player.animateID = pid;
4781
4783
  if (player.resize && this.bound.inited)
@@ -5012,9 +5014,13 @@ var MultiTouchSpace = class extends Space {
5012
5014
  this._mouseOut = this._mouseOut.bind(this);
5013
5015
  this._mouseMove = this._mouseMove.bind(this);
5014
5016
  this._mouseClick = this._mouseClick.bind(this);
5017
+ this._pointerDown = this._pointerDown.bind(this);
5018
+ this._pointerUp = this._pointerUp.bind(this);
5015
5019
  this._contextMenu = this._contextMenu.bind(this);
5016
5020
  this.bindCanvas("mousedown", this._mouseDown, {}, customTarget);
5021
+ this.bindCanvas("pointerdown", this._pointerDown, {}, customTarget);
5017
5022
  this.bindCanvas("mouseup", this._mouseUp, {}, customTarget);
5023
+ this.bindCanvas("pointerup", this._pointerUp, {}, customTarget);
5018
5024
  this.bindCanvas("mouseover", this._mouseOver, {}, customTarget);
5019
5025
  this.bindCanvas("mouseout", this._mouseOut, {}, customTarget);
5020
5026
  this.bindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -5023,7 +5029,9 @@ var MultiTouchSpace = class extends Space {
5023
5029
  this._hasMouse = true;
5024
5030
  } else {
5025
5031
  this.unbindCanvas("mousedown", this._mouseDown, {}, customTarget);
5032
+ this.unbindCanvas("pointerdown", this._pointerDown, {}, customTarget);
5026
5033
  this.unbindCanvas("mouseup", this._mouseUp, {}, customTarget);
5034
+ this.unbindCanvas("pointerup", this._pointerUp, {}, customTarget);
5027
5035
  this.unbindCanvas("mouseover", this._mouseOver, {}, customTarget);
5028
5036
  this.unbindCanvas("mouseout", this._mouseOut, {}, customTarget);
5029
5037
  this.unbindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -5135,6 +5143,13 @@ var MultiTouchSpace = class extends Space {
5135
5143
  this._pressed = true;
5136
5144
  return false;
5137
5145
  }
5146
+ _pointerDown(evt) {
5147
+ this._mouseAction(UIPointerActions.pointerdown, evt);
5148
+ if (evt.target instanceof Element) {
5149
+ evt.target.setPointerCapture(evt.pointerId);
5150
+ }
5151
+ return false;
5152
+ }
5138
5153
  /**
5139
5154
  * MouseUp handler.
5140
5155
  * @param evt
@@ -5149,6 +5164,16 @@ var MultiTouchSpace = class extends Space {
5149
5164
  this._dragged = false;
5150
5165
  return false;
5151
5166
  }
5167
+ _pointerUp(evt) {
5168
+ this._mouseAction(UIPointerActions.pointerup, evt);
5169
+ if (evt.target instanceof Element) {
5170
+ evt.target.releasePointerCapture(evt.pointerId);
5171
+ if (this._dragged)
5172
+ this._mouseAction(UIPointerActions.drop, evt);
5173
+ this._dragged = false;
5174
+ }
5175
+ return false;
5176
+ }
5152
5177
  /**
5153
5178
  * MouseMove handler.
5154
5179
  * @param evt
package/dist/index.mjs CHANGED
@@ -4232,6 +4232,8 @@ var UIPointerActions = {
4232
4232
  click: "click",
4233
4233
  keydown: "keydown",
4234
4234
  keyup: "keyup",
4235
+ pointerdown: "pointerdown",
4236
+ pointerup: "pointerup",
4235
4237
  contextmenu: "contextmenu",
4236
4238
  all: "all"
4237
4239
  };
@@ -4707,7 +4709,7 @@ var Space = class {
4707
4709
  add(p) {
4708
4710
  let player = typeof p == "function" ? { animate: p } : p;
4709
4711
  let k = this.playerCount++;
4710
- let pid = this.id + k;
4712
+ let pid = player.animateID || this.id + k;
4711
4713
  this.players[pid] = player;
4712
4714
  player.animateID = pid;
4713
4715
  if (player.resize && this.bound.inited)
@@ -4944,9 +4946,13 @@ var MultiTouchSpace = class extends Space {
4944
4946
  this._mouseOut = this._mouseOut.bind(this);
4945
4947
  this._mouseMove = this._mouseMove.bind(this);
4946
4948
  this._mouseClick = this._mouseClick.bind(this);
4949
+ this._pointerDown = this._pointerDown.bind(this);
4950
+ this._pointerUp = this._pointerUp.bind(this);
4947
4951
  this._contextMenu = this._contextMenu.bind(this);
4948
4952
  this.bindCanvas("mousedown", this._mouseDown, {}, customTarget);
4953
+ this.bindCanvas("pointerdown", this._pointerDown, {}, customTarget);
4949
4954
  this.bindCanvas("mouseup", this._mouseUp, {}, customTarget);
4955
+ this.bindCanvas("pointerup", this._pointerUp, {}, customTarget);
4950
4956
  this.bindCanvas("mouseover", this._mouseOver, {}, customTarget);
4951
4957
  this.bindCanvas("mouseout", this._mouseOut, {}, customTarget);
4952
4958
  this.bindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -4955,7 +4961,9 @@ var MultiTouchSpace = class extends Space {
4955
4961
  this._hasMouse = true;
4956
4962
  } else {
4957
4963
  this.unbindCanvas("mousedown", this._mouseDown, {}, customTarget);
4964
+ this.unbindCanvas("pointerdown", this._pointerDown, {}, customTarget);
4958
4965
  this.unbindCanvas("mouseup", this._mouseUp, {}, customTarget);
4966
+ this.unbindCanvas("pointerup", this._pointerUp, {}, customTarget);
4959
4967
  this.unbindCanvas("mouseover", this._mouseOver, {}, customTarget);
4960
4968
  this.unbindCanvas("mouseout", this._mouseOut, {}, customTarget);
4961
4969
  this.unbindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -5067,6 +5075,13 @@ var MultiTouchSpace = class extends Space {
5067
5075
  this._pressed = true;
5068
5076
  return false;
5069
5077
  }
5078
+ _pointerDown(evt) {
5079
+ this._mouseAction(UIPointerActions.pointerdown, evt);
5080
+ if (evt.target instanceof Element) {
5081
+ evt.target.setPointerCapture(evt.pointerId);
5082
+ }
5083
+ return false;
5084
+ }
5070
5085
  /**
5071
5086
  * MouseUp handler.
5072
5087
  * @param evt
@@ -5081,6 +5096,16 @@ var MultiTouchSpace = class extends Space {
5081
5096
  this._dragged = false;
5082
5097
  return false;
5083
5098
  }
5099
+ _pointerUp(evt) {
5100
+ this._mouseAction(UIPointerActions.pointerup, evt);
5101
+ if (evt.target instanceof Element) {
5102
+ evt.target.releasePointerCapture(evt.pointerId);
5103
+ if (this._dragged)
5104
+ this._mouseAction(UIPointerActions.drop, evt);
5105
+ this._dragged = false;
5106
+ }
5107
+ return false;
5108
+ }
5084
5109
  /**
5085
5110
  * MouseMove handler.
5086
5111
  * @param evt
package/dist/pts.js CHANGED
@@ -1,4 +1,4 @@
1
- /* Copyright © 2017-2023 William Ngan and contributors.
1
+ /* Copyright © 2017-2024 William Ngan and contributors.
2
2
  Licensed under Apache 2.0 License.
3
3
  See https://github.com/williamngan/pts for details. */
4
4
  (() => {
@@ -4318,6 +4318,8 @@ See https://github.com/williamngan/pts for details. */
4318
4318
  click: "click",
4319
4319
  keydown: "keydown",
4320
4320
  keyup: "keyup",
4321
+ pointerdown: "pointerdown",
4322
+ pointerup: "pointerup",
4321
4323
  contextmenu: "contextmenu",
4322
4324
  all: "all"
4323
4325
  };
@@ -4793,7 +4795,7 @@ See https://github.com/williamngan/pts for details. */
4793
4795
  add(p) {
4794
4796
  let player = typeof p == "function" ? { animate: p } : p;
4795
4797
  let k = this.playerCount++;
4796
- let pid = this.id + k;
4798
+ let pid = player.animateID || this.id + k;
4797
4799
  this.players[pid] = player;
4798
4800
  player.animateID = pid;
4799
4801
  if (player.resize && this.bound.inited)
@@ -5030,9 +5032,13 @@ See https://github.com/williamngan/pts for details. */
5030
5032
  this._mouseOut = this._mouseOut.bind(this);
5031
5033
  this._mouseMove = this._mouseMove.bind(this);
5032
5034
  this._mouseClick = this._mouseClick.bind(this);
5035
+ this._pointerDown = this._pointerDown.bind(this);
5036
+ this._pointerUp = this._pointerUp.bind(this);
5033
5037
  this._contextMenu = this._contextMenu.bind(this);
5034
5038
  this.bindCanvas("mousedown", this._mouseDown, {}, customTarget);
5039
+ this.bindCanvas("pointerdown", this._pointerDown, {}, customTarget);
5035
5040
  this.bindCanvas("mouseup", this._mouseUp, {}, customTarget);
5041
+ this.bindCanvas("pointerup", this._pointerUp, {}, customTarget);
5036
5042
  this.bindCanvas("mouseover", this._mouseOver, {}, customTarget);
5037
5043
  this.bindCanvas("mouseout", this._mouseOut, {}, customTarget);
5038
5044
  this.bindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -5041,7 +5047,9 @@ See https://github.com/williamngan/pts for details. */
5041
5047
  this._hasMouse = true;
5042
5048
  } else {
5043
5049
  this.unbindCanvas("mousedown", this._mouseDown, {}, customTarget);
5050
+ this.unbindCanvas("pointerdown", this._pointerDown, {}, customTarget);
5044
5051
  this.unbindCanvas("mouseup", this._mouseUp, {}, customTarget);
5052
+ this.unbindCanvas("pointerup", this._pointerUp, {}, customTarget);
5045
5053
  this.unbindCanvas("mouseover", this._mouseOver, {}, customTarget);
5046
5054
  this.unbindCanvas("mouseout", this._mouseOut, {}, customTarget);
5047
5055
  this.unbindCanvas("mousemove", this._mouseMove, {}, customTarget);
@@ -5153,6 +5161,13 @@ See https://github.com/williamngan/pts for details. */
5153
5161
  this._pressed = true;
5154
5162
  return false;
5155
5163
  }
5164
+ _pointerDown(evt) {
5165
+ this._mouseAction(UIPointerActions.pointerdown, evt);
5166
+ if (evt.target instanceof Element) {
5167
+ evt.target.setPointerCapture(evt.pointerId);
5168
+ }
5169
+ return false;
5170
+ }
5156
5171
  /**
5157
5172
  * MouseUp handler.
5158
5173
  * @param evt
@@ -5167,6 +5182,16 @@ See https://github.com/williamngan/pts for details. */
5167
5182
  this._dragged = false;
5168
5183
  return false;
5169
5184
  }
5185
+ _pointerUp(evt) {
5186
+ this._mouseAction(UIPointerActions.pointerup, evt);
5187
+ if (evt.target instanceof Element) {
5188
+ evt.target.releasePointerCapture(evt.pointerId);
5189
+ if (this._dragged)
5190
+ this._mouseAction(UIPointerActions.drop, evt);
5191
+ this._dragged = false;
5192
+ }
5193
+ return false;
5194
+ }
5170
5195
  /**
5171
5196
  * MouseMove handler.
5172
5197
  * @param evt