abcjs 6.1.3 → 6.1.5

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 + ")");
@@ -28235,8 +28235,10 @@ function getTarget(target) {
28235
28235
  var found = target.getAttribute("selectable");
28236
28236
 
28237
28237
  while (!found) {
28238
- target = target.parentElement;
28239
- if (target.tagName === "svg") found = true;else found = target.getAttribute("selectable");
28238
+ if (!target.parentElement) found = true;else {
28239
+ target = target.parentElement;
28240
+ if (target.tagName === "svg") found = true;else found = target.getAttribute("selectable");
28241
+ }
28240
28242
  }
28241
28243
 
28242
28244
  return target;
@@ -28271,6 +28273,7 @@ function getMousePosition(self, ev) {
28271
28273
  }
28272
28274
 
28273
28275
  function attachMissingTouchEventAttributes(touchEv) {
28276
+ if (!touchEv || !touchEv.target || !touchEv.touches || touchEv.touches.length < 1) return;
28274
28277
  var rect = touchEv.target.getBoundingClientRect();
28275
28278
  var offsetX = touchEv.touches[0].pageX - rect.left;
28276
28279
  var offsetY = touchEv.touches[0].pageY - rect.top;
@@ -28286,12 +28289,12 @@ function mouseDown(ev) {
28286
28289
 
28287
28290
  if (ev.type === 'touchstart') {
28288
28291
  attachMissingTouchEventAttributes(ev);
28289
- _ev = ev.touches[0];
28292
+ if (ev.touches.length > 0) _ev = ev.touches[0];
28290
28293
  }
28291
28294
 
28292
28295
  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
28296
 
28294
- if (positioning.clickedOn >= 0 && (ev.type === 'touchstart' || ev.button === 0)) {
28297
+ if (positioning.clickedOn >= 0 && (ev.type === 'touchstart' || ev.button === 0) && this.selectables[positioning.clickedOn]) {
28295
28298
  this.dragTarget = this.selectables[positioning.clickedOn];
28296
28299
  this.dragIndex = positioning.clickedOn;
28297
28300
  this.dragMechanism = "mouse";
@@ -28312,12 +28315,12 @@ function mouseMove(ev) {
28312
28315
 
28313
28316
  if (ev.type === 'touchmove') {
28314
28317
  attachMissingTouchEventAttributes(ev);
28315
- _ev = ev.touches[0];
28318
+ if (ev.touches.length > 0) _ev = ev.touches[0];
28316
28319
  }
28317
28320
 
28318
28321
  this.lastTouchMove = ev; // "this" is the EngraverController because of the bind(this) when setting the event listener.
28319
28322
 
28320
- if (!this.dragTarget || !this.dragging || !this.dragTarget.isDraggable || this.dragMechanism !== 'mouse') return;
28323
+ if (!this.dragTarget || !this.dragging || !this.dragTarget.isDraggable || this.dragMechanism !== 'mouse' || !this.dragMouseStart) return;
28321
28324
  var positioning = getMousePosition(this, _ev);
28322
28325
  var yDist = Math.round((positioning.y - this.dragMouseStart.y) / spacing.STEP);
28323
28326
 
@@ -28331,9 +28334,9 @@ function mouseUp(ev) {
28331
28334
  // "this" is the EngraverController because of the bind(this) when setting the event listener.
28332
28335
  var _ev = ev;
28333
28336
 
28334
- if (ev.type === 'touchend') {
28337
+ if (ev.type === 'touchend' && this.lastTouchMove) {
28335
28338
  attachMissingTouchEventAttributes(this.lastTouchMove);
28336
- _ev = this.lastTouchMove.touches[0];
28339
+ if (this.lastTouchMove.touches.length > 0) _ev = this.lastTouchMove.touches[0];
28337
28340
  }
28338
28341
 
28339
28342
  if (!this.dragTarget) return;
@@ -28400,13 +28403,13 @@ function notifySelect(target, dragStep, dragMax, dragIndex, ev) {
28400
28403
  if (target.staffPos) analysis.staffPos = target.staffPos;
28401
28404
  var closest = ev.target;
28402
28405
 
28403
- while (!closest.dataset.name && closest.tagName.toLowerCase() !== 'svg') {
28406
+ while (closest && !closest.dataset.name && closest.tagName.toLowerCase() !== 'svg') {
28404
28407
  closest = closest.parentNode;
28405
28408
  }
28406
28409
 
28407
28410
  var parent = ev.target;
28408
28411
 
28409
- while (!parent.dataset.index && parent.tagName.toLowerCase() !== 'svg') {
28412
+ while (parent && !parent.dataset.index && parent.tagName.toLowerCase() !== 'svg') {
28410
28413
  parent = parent.parentNode;
28411
28414
  }
28412
28415
 
@@ -29151,7 +29154,7 @@ module.exports = unhighlight;
29151
29154
  \********************/
29152
29155
  /***/ (function(module) {
29153
29156
 
29154
- var version = '6.1.3';
29157
+ var version = '6.1.5';
29155
29158
  module.exports = version;
29156
29159
 
29157
29160
  /***/ })