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.
- package/RELEASE.md +12 -0
- package/dist/abcjs-basic-min.js +2 -2
- package/dist/abcjs-basic.js +17 -14
- 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 +24 -15
- 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++;
|
|
@@ -200,11 +200,15 @@ function getTarget(target) {
|
|
|
200
200
|
|
|
201
201
|
var found = target.getAttribute("selectable");
|
|
202
202
|
while (!found) {
|
|
203
|
-
|
|
204
|
-
if (target.tagName === "svg")
|
|
203
|
+
if (!target.parentElement)
|
|
205
204
|
found = true;
|
|
206
|
-
else
|
|
207
|
-
|
|
205
|
+
else {
|
|
206
|
+
target = target.parentElement;
|
|
207
|
+
if (target.tagName === "svg")
|
|
208
|
+
found = true;
|
|
209
|
+
else
|
|
210
|
+
found = target.getAttribute("selectable");
|
|
211
|
+
}
|
|
208
212
|
}
|
|
209
213
|
return target;
|
|
210
214
|
}
|
|
@@ -234,6 +238,8 @@ function getMousePosition(self, ev) {
|
|
|
234
238
|
}
|
|
235
239
|
|
|
236
240
|
function attachMissingTouchEventAttributes(touchEv) {
|
|
241
|
+
if (!touchEv || !touchEv.target || !touchEv.touches || touchEv.touches.length < 1)
|
|
242
|
+
return
|
|
237
243
|
var rect = touchEv.target.getBoundingClientRect();
|
|
238
244
|
var offsetX = touchEv.touches[0].pageX - rect.left;
|
|
239
245
|
var offsetY = touchEv.touches[0].pageY - rect.top;
|
|
@@ -250,13 +256,14 @@ function mouseDown(ev) {
|
|
|
250
256
|
var _ev = ev;
|
|
251
257
|
if (ev.type === 'touchstart') {
|
|
252
258
|
attachMissingTouchEventAttributes(ev);
|
|
253
|
-
|
|
259
|
+
if (ev.touches.length > 0)
|
|
260
|
+
_ev = ev.touches[0];
|
|
254
261
|
}
|
|
255
262
|
|
|
256
263
|
var positioning = getMousePosition(this, _ev);
|
|
257
264
|
|
|
258
265
|
// 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)) {
|
|
266
|
+
if (positioning.clickedOn >= 0 && (ev.type === 'touchstart' || ev.button === 0) && this.selectables[positioning.clickedOn]) {
|
|
260
267
|
this.dragTarget = this.selectables[positioning.clickedOn];
|
|
261
268
|
this.dragIndex = positioning.clickedOn;
|
|
262
269
|
this.dragMechanism = "mouse";
|
|
@@ -272,12 +279,13 @@ function mouseMove(ev) {
|
|
|
272
279
|
var _ev = ev;
|
|
273
280
|
if (ev.type === 'touchmove') {
|
|
274
281
|
attachMissingTouchEventAttributes(ev);
|
|
275
|
-
|
|
282
|
+
if (ev.touches.length > 0)
|
|
283
|
+
_ev = ev.touches[0];
|
|
276
284
|
}
|
|
277
285
|
this.lastTouchMove = ev;
|
|
278
286
|
// "this" is the EngraverController because of the bind(this) when setting the event listener.
|
|
279
287
|
|
|
280
|
-
if (!this.dragTarget || !this.dragging || !this.dragTarget.isDraggable || this.dragMechanism !== 'mouse')
|
|
288
|
+
if (!this.dragTarget || !this.dragging || !this.dragTarget.isDraggable || this.dragMechanism !== 'mouse' || !this.dragMouseStart)
|
|
281
289
|
return;
|
|
282
290
|
|
|
283
291
|
var positioning = getMousePosition(this, _ev);
|
|
@@ -292,9 +300,10 @@ function mouseMove(ev) {
|
|
|
292
300
|
function mouseUp(ev) {
|
|
293
301
|
// "this" is the EngraverController because of the bind(this) when setting the event listener.
|
|
294
302
|
var _ev = ev;
|
|
295
|
-
if (ev.type === 'touchend') {
|
|
303
|
+
if (ev.type === 'touchend' && this.lastTouchMove) {
|
|
296
304
|
attachMissingTouchEventAttributes(this.lastTouchMove);
|
|
297
|
-
|
|
305
|
+
if (this.lastTouchMove.touches.length > 0)
|
|
306
|
+
_ev = this.lastTouchMove.touches[0];
|
|
298
307
|
}
|
|
299
308
|
|
|
300
309
|
if (!this.dragTarget)
|
|
@@ -348,10 +357,10 @@ function notifySelect(target, dragStep, dragMax, dragIndex, ev) {
|
|
|
348
357
|
if (target.staffPos)
|
|
349
358
|
analysis.staffPos = target.staffPos;
|
|
350
359
|
var closest = ev.target;
|
|
351
|
-
while (!closest.dataset.name && closest.tagName.toLowerCase() !== 'svg')
|
|
360
|
+
while (closest && !closest.dataset.name && closest.tagName.toLowerCase() !== 'svg')
|
|
352
361
|
closest = closest.parentNode;
|
|
353
362
|
var parent = ev.target;
|
|
354
|
-
while (!parent.dataset.index && parent.tagName.toLowerCase() !== 'svg')
|
|
363
|
+
while (parent && !parent.dataset.index && parent.tagName.toLowerCase() !== 'svg')
|
|
355
364
|
parent = parent.parentNode;
|
|
356
365
|
analysis.name = parent.dataset.name;
|
|
357
366
|
analysis.clickedName = closest.dataset.name;
|
package/version.js
CHANGED