abcjs 6.1.3 → 6.1.4

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.
@@ -28068,7 +28068,7 @@ function getCoord(ev) {
28068
28068
  yOffset = svg.viewBox.baseVal.y;
28069
28069
  }
28070
28070
 
28071
- var svgClicked = ev.target.tagName === "svg";
28071
+ var svgClicked = ev.target && ev.target.tagName === "svg";
28072
28072
  var x;
28073
28073
  var y;
28074
28074
 
@@ -28122,7 +28122,7 @@ function keyboardSelection(ev) {
28122
28122
  this.dragTarget = this.selectables[index];
28123
28123
  this.dragIndex = index;
28124
28124
 
28125
- if (this.dragTarget.isDraggable) {
28125
+ if (this.dragTarget && this.dragTarget.isDraggable) {
28126
28126
  if (this.dragging && this.dragTarget.isDraggable) this.dragTarget.absEl.highlight(undefined, this.dragColor);
28127
28127
  this.dragYStep--;
28128
28128
  this.dragTarget.svgEl.setAttribute("transform", "translate(0," + this.dragYStep * spacing.STEP + ")");
@@ -28137,7 +28137,7 @@ function keyboardSelection(ev) {
28137
28137
  this.dragIndex = index;
28138
28138
  this.dragMechanism = "keyboard";
28139
28139
 
28140
- if (this.dragTarget.isDraggable) {
28140
+ if (this.dragTarget && this.dragTarget.isDraggable) {
28141
28141
  if (this.dragging && this.dragTarget.isDraggable) this.dragTarget.absEl.highlight(undefined, this.dragColor);
28142
28142
  this.dragYStep++;
28143
28143
  this.dragTarget.svgEl.setAttribute("transform", "translate(0," + this.dragYStep * spacing.STEP + ")");
@@ -28271,6 +28271,7 @@ function getMousePosition(self, ev) {
28271
28271
  }
28272
28272
 
28273
28273
  function attachMissingTouchEventAttributes(touchEv) {
28274
+ if (!touchEv || !touchEv.target || !touchEv.touches || touchEv.touches.length < 1) return;
28274
28275
  var rect = touchEv.target.getBoundingClientRect();
28275
28276
  var offsetX = touchEv.touches[0].pageX - rect.left;
28276
28277
  var offsetY = touchEv.touches[0].pageY - rect.top;
@@ -28286,12 +28287,12 @@ function mouseDown(ev) {
28286
28287
 
28287
28288
  if (ev.type === 'touchstart') {
28288
28289
  attachMissingTouchEventAttributes(ev);
28289
- _ev = ev.touches[0];
28290
+ if (ev.touches.length > 0) _ev = ev.touches[0];
28290
28291
  }
28291
28292
 
28292
28293
  var positioning = getMousePosition(this, _ev); // Only start dragging if the user clicked close enough to an element and clicked with the main mouse button.
28293
28294
 
28294
- if (positioning.clickedOn >= 0 && (ev.type === 'touchstart' || ev.button === 0)) {
28295
+ if (positioning.clickedOn >= 0 && (ev.type === 'touchstart' || ev.button === 0) && this.selectables[positioning.clickedOn]) {
28295
28296
  this.dragTarget = this.selectables[positioning.clickedOn];
28296
28297
  this.dragIndex = positioning.clickedOn;
28297
28298
  this.dragMechanism = "mouse";
@@ -28312,12 +28313,12 @@ function mouseMove(ev) {
28312
28313
 
28313
28314
  if (ev.type === 'touchmove') {
28314
28315
  attachMissingTouchEventAttributes(ev);
28315
- _ev = ev.touches[0];
28316
+ if (ev.touches.length > 0) _ev = ev.touches[0];
28316
28317
  }
28317
28318
 
28318
28319
  this.lastTouchMove = ev; // "this" is the EngraverController because of the bind(this) when setting the event listener.
28319
28320
 
28320
- if (!this.dragTarget || !this.dragging || !this.dragTarget.isDraggable || this.dragMechanism !== 'mouse') return;
28321
+ if (!this.dragTarget || !this.dragging || !this.dragTarget.isDraggable || this.dragMechanism !== 'mouse' || !this.dragMouseStart) return;
28321
28322
  var positioning = getMousePosition(this, _ev);
28322
28323
  var yDist = Math.round((positioning.y - this.dragMouseStart.y) / spacing.STEP);
28323
28324
 
@@ -28331,9 +28332,9 @@ function mouseUp(ev) {
28331
28332
  // "this" is the EngraverController because of the bind(this) when setting the event listener.
28332
28333
  var _ev = ev;
28333
28334
 
28334
- if (ev.type === 'touchend') {
28335
+ if (ev.type === 'touchend' && this.lastTouchMove) {
28335
28336
  attachMissingTouchEventAttributes(this.lastTouchMove);
28336
- _ev = this.lastTouchMove.touches[0];
28337
+ if (ev.touches.length > 0) _ev = this.lastTouchMove.touches[0];
28337
28338
  }
28338
28339
 
28339
28340
  if (!this.dragTarget) return;
@@ -28400,13 +28401,13 @@ function notifySelect(target, dragStep, dragMax, dragIndex, ev) {
28400
28401
  if (target.staffPos) analysis.staffPos = target.staffPos;
28401
28402
  var closest = ev.target;
28402
28403
 
28403
- while (!closest.dataset.name && closest.tagName.toLowerCase() !== 'svg') {
28404
+ while (closest && !closest.dataset.name && closest.tagName.toLowerCase() !== 'svg') {
28404
28405
  closest = closest.parentNode;
28405
28406
  }
28406
28407
 
28407
28408
  var parent = ev.target;
28408
28409
 
28409
- while (!parent.dataset.index && parent.tagName.toLowerCase() !== 'svg') {
28410
+ while (parent && !parent.dataset.index && parent.tagName.toLowerCase() !== 'svg') {
28410
28411
  parent = parent.parentNode;
28411
28412
  }
28412
28413
 
@@ -29151,7 +29152,7 @@ module.exports = unhighlight;
29151
29152
  \********************/
29152
29153
  /***/ (function(module) {
29153
29154
 
29154
- var version = '6.1.3';
29155
+ var version = '6.1.4';
29155
29156
  module.exports = version;
29156
29157
 
29157
29158
  /***/ })