@alepot55/chessboardjs 2.3.6 → 2.3.7

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
@@ -3,7 +3,7 @@
3
3
  "chess.js": "^1.0.0"
4
4
  },
5
5
  "name": "@alepot55/chessboardjs",
6
- "version": "2.3.6",
6
+ "version": "2.3.7",
7
7
  "main": "src/index.js",
8
8
  "type": "module",
9
9
  "scripts": {
@@ -201,10 +201,22 @@ class Piece {
201
201
 
202
202
  setDrag(f) {
203
203
  if (!this.element) { console.debug(`[Piece] setDrag: ${this.id} - element is null`); return; }
204
+ // Remove previous handlers
205
+ this.element.onmousedown = null;
206
+ this.element.ontouchstart = null;
207
+ this.element.ondragstart = null;
208
+ if (window.PointerEvent) {
209
+ this.element.onpointerdown = null;
210
+ }
211
+ // Set new handlers
204
212
  this.element.ondragstart = (e) => { e.preventDefault() };
205
213
  this.element.onmousedown = f;
206
214
  this.element.ontouchstart = f; // Drag touch
207
- console.debug(`[Piece] setDrag: ${this.id}`);
215
+ if (window.PointerEvent) {
216
+ this.element.onpointerdown = f;
217
+ console.debug(`[Piece] setDrag: pointerdown set for ${this.id}`);
218
+ }
219
+ console.debug(`[Piece] setDrag: mousedown/ontouchstart set for ${this.id}`);
208
220
  }
209
221
 
210
222
  destroy() {