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.
- package/RELEASE.md +6 -0
- package/dist/abcjs-basic-min.js +2 -2
- package/dist/abcjs-basic.js +13 -12
- package/dist/abcjs-basic.js.map +1 -1
- package/dist/abcjs-plugin-min.js +2 -2
- package/package.json +1 -1
- package/src/write/selection.js +16 -11
- package/version.js +1 -1
package/package.json
CHANGED
package/src/write/selection.js
CHANGED
|
@@ -41,7 +41,7 @@ function getCoord(ev) {
|
|
|
41
41
|
yOffset = svg.viewBox.baseVal.y
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
-
var svgClicked = ev.target.tagName === "svg";
|
|
44
|
+
var svgClicked = ev.target && ev.target.tagName === "svg";
|
|
45
45
|
var x;
|
|
46
46
|
var y;
|
|
47
47
|
if (svgClicked) {
|
|
@@ -93,7 +93,7 @@ function keyboardSelection(ev) {
|
|
|
93
93
|
handled = true;
|
|
94
94
|
this.dragTarget = this.selectables[index];
|
|
95
95
|
this.dragIndex = index;
|
|
96
|
-
if (this.dragTarget.isDraggable) {
|
|
96
|
+
if (this.dragTarget && this.dragTarget.isDraggable) {
|
|
97
97
|
if (this.dragging && this.dragTarget.isDraggable)
|
|
98
98
|
this.dragTarget.absEl.highlight(undefined, this.dragColor);
|
|
99
99
|
this.dragYStep--;
|
|
@@ -105,7 +105,7 @@ function keyboardSelection(ev) {
|
|
|
105
105
|
this.dragTarget = this.selectables[index];
|
|
106
106
|
this.dragIndex = index;
|
|
107
107
|
this.dragMechanism = "keyboard";
|
|
108
|
-
if (this.dragTarget.isDraggable) {
|
|
108
|
+
if (this.dragTarget && this.dragTarget.isDraggable) {
|
|
109
109
|
if (this.dragging && this.dragTarget.isDraggable)
|
|
110
110
|
this.dragTarget.absEl.highlight(undefined, this.dragColor);
|
|
111
111
|
this.dragYStep++;
|
|
@@ -234,6 +234,8 @@ function getMousePosition(self, ev) {
|
|
|
234
234
|
}
|
|
235
235
|
|
|
236
236
|
function attachMissingTouchEventAttributes(touchEv) {
|
|
237
|
+
if (!touchEv || !touchEv.target || !touchEv.touches || touchEv.touches.length < 1)
|
|
238
|
+
return
|
|
237
239
|
var rect = touchEv.target.getBoundingClientRect();
|
|
238
240
|
var offsetX = touchEv.touches[0].pageX - rect.left;
|
|
239
241
|
var offsetY = touchEv.touches[0].pageY - rect.top;
|
|
@@ -250,13 +252,14 @@ function mouseDown(ev) {
|
|
|
250
252
|
var _ev = ev;
|
|
251
253
|
if (ev.type === 'touchstart') {
|
|
252
254
|
attachMissingTouchEventAttributes(ev);
|
|
253
|
-
|
|
255
|
+
if (ev.touches.length > 0)
|
|
256
|
+
_ev = ev.touches[0];
|
|
254
257
|
}
|
|
255
258
|
|
|
256
259
|
var positioning = getMousePosition(this, _ev);
|
|
257
260
|
|
|
258
261
|
// Only start dragging if the user clicked close enough to an element and clicked with the main mouse button.
|
|
259
|
-
if (positioning.clickedOn >= 0 && (ev.type === 'touchstart' || ev.button === 0)) {
|
|
262
|
+
if (positioning.clickedOn >= 0 && (ev.type === 'touchstart' || ev.button === 0) && this.selectables[positioning.clickedOn]) {
|
|
260
263
|
this.dragTarget = this.selectables[positioning.clickedOn];
|
|
261
264
|
this.dragIndex = positioning.clickedOn;
|
|
262
265
|
this.dragMechanism = "mouse";
|
|
@@ -272,12 +275,13 @@ function mouseMove(ev) {
|
|
|
272
275
|
var _ev = ev;
|
|
273
276
|
if (ev.type === 'touchmove') {
|
|
274
277
|
attachMissingTouchEventAttributes(ev);
|
|
275
|
-
|
|
278
|
+
if (ev.touches.length > 0)
|
|
279
|
+
_ev = ev.touches[0];
|
|
276
280
|
}
|
|
277
281
|
this.lastTouchMove = ev;
|
|
278
282
|
// "this" is the EngraverController because of the bind(this) when setting the event listener.
|
|
279
283
|
|
|
280
|
-
if (!this.dragTarget || !this.dragging || !this.dragTarget.isDraggable || this.dragMechanism !== 'mouse')
|
|
284
|
+
if (!this.dragTarget || !this.dragging || !this.dragTarget.isDraggable || this.dragMechanism !== 'mouse' || !this.dragMouseStart)
|
|
281
285
|
return;
|
|
282
286
|
|
|
283
287
|
var positioning = getMousePosition(this, _ev);
|
|
@@ -292,9 +296,10 @@ function mouseMove(ev) {
|
|
|
292
296
|
function mouseUp(ev) {
|
|
293
297
|
// "this" is the EngraverController because of the bind(this) when setting the event listener.
|
|
294
298
|
var _ev = ev;
|
|
295
|
-
if (ev.type === 'touchend') {
|
|
299
|
+
if (ev.type === 'touchend' && this.lastTouchMove) {
|
|
296
300
|
attachMissingTouchEventAttributes(this.lastTouchMove);
|
|
297
|
-
|
|
301
|
+
if (ev.touches.length > 0)
|
|
302
|
+
_ev = this.lastTouchMove.touches[0];
|
|
298
303
|
}
|
|
299
304
|
|
|
300
305
|
if (!this.dragTarget)
|
|
@@ -348,10 +353,10 @@ function notifySelect(target, dragStep, dragMax, dragIndex, ev) {
|
|
|
348
353
|
if (target.staffPos)
|
|
349
354
|
analysis.staffPos = target.staffPos;
|
|
350
355
|
var closest = ev.target;
|
|
351
|
-
while (!closest.dataset.name && closest.tagName.toLowerCase() !== 'svg')
|
|
356
|
+
while (closest && !closest.dataset.name && closest.tagName.toLowerCase() !== 'svg')
|
|
352
357
|
closest = closest.parentNode;
|
|
353
358
|
var parent = ev.target;
|
|
354
|
-
while (!parent.dataset.index && parent.tagName.toLowerCase() !== 'svg')
|
|
359
|
+
while (parent && !parent.dataset.index && parent.tagName.toLowerCase() !== 'svg')
|
|
355
360
|
parent = parent.parentNode;
|
|
356
361
|
analysis.name = parent.dataset.name;
|
|
357
362
|
analysis.clickedName = closest.dataset.name;
|
package/version.js
CHANGED