abcjs 6.1.0 → 6.1.1
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/README.md +4 -0
- package/RELEASE.md +14 -0
- package/SECURITY.md +9 -0
- package/dist/abcjs-basic-min.js +2 -2
- package/dist/abcjs-basic.js +145 -128
- package/dist/abcjs-basic.js.map +1 -1
- package/dist/abcjs-plugin-min.js +2 -2
- package/package.json +1 -1
- package/src/api/abc_tunebook_svg.js +2 -98
- package/src/write/abc_engraver_controller.js +64 -1
- package/src/write/draw/draw.js +8 -0
- package/src/write/draw/staff-group.js +5 -5
- package/src/write/selection.js +48 -12
- package/types/index.d.ts +44 -0
- package/version.js +1 -1
package/dist/abcjs-basic.js
CHANGED
|
@@ -1101,101 +1101,6 @@ function renderOne(div, tune, params, tuneNumber, lineOffset) {
|
|
|
1101
1101
|
var parent = div.parentNode;
|
|
1102
1102
|
parent.style.width = div.style.width;
|
|
1103
1103
|
}
|
|
1104
|
-
}
|
|
1105
|
-
|
|
1106
|
-
function renderEachLineSeparately(div, tune, params, tuneNumber) {
|
|
1107
|
-
function initializeTuneLine(tune) {
|
|
1108
|
-
var obj = new Tune();
|
|
1109
|
-
obj.formatting = tune.formatting;
|
|
1110
|
-
obj.media = tune.media;
|
|
1111
|
-
obj.version = tune.version;
|
|
1112
|
-
return obj;
|
|
1113
|
-
} // Before rendering, chop up the returned tune into an array where each element is a line.
|
|
1114
|
-
// The first element of the array gets the title and other items that go on top, the last element
|
|
1115
|
-
// of the array gets the extra text that goes on bottom. Each element gets any non-music info that comes before it.
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
var tunes = [];
|
|
1119
|
-
var tuneLine;
|
|
1120
|
-
|
|
1121
|
-
for (var i = 0; i < tune.lines.length; i++) {
|
|
1122
|
-
var line = tune.lines[i];
|
|
1123
|
-
if (!tuneLine) tuneLine = initializeTuneLine(tune);
|
|
1124
|
-
|
|
1125
|
-
if (i === 0) {
|
|
1126
|
-
// These items go on top of the music
|
|
1127
|
-
tuneLine.copyTopInfo(tune);
|
|
1128
|
-
} // push the lines until we get to a music line
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
tuneLine.lines.push(line);
|
|
1132
|
-
|
|
1133
|
-
if (line.staff) {
|
|
1134
|
-
tunes.push(tuneLine);
|
|
1135
|
-
tuneLine = undefined;
|
|
1136
|
-
}
|
|
1137
|
-
} // Add any extra stuff to the last line.
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
if (tuneLine) {
|
|
1141
|
-
var lastLine = tunes[tunes.length - 1];
|
|
1142
|
-
|
|
1143
|
-
for (var j = 0; j < tuneLine.lines.length; j++) {
|
|
1144
|
-
lastLine.lines.push(tuneLine.lines[j]);
|
|
1145
|
-
}
|
|
1146
|
-
} // These items go below the music
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
tuneLine = tunes[tunes.length - 1];
|
|
1150
|
-
tuneLine.copyBottomInfo(tune); // Now create sub-divs and render each line. Need to copy the params to change the padding for the interior slices.
|
|
1151
|
-
|
|
1152
|
-
var ep = {};
|
|
1153
|
-
|
|
1154
|
-
for (var key in params) {
|
|
1155
|
-
if (params.hasOwnProperty(key)) {
|
|
1156
|
-
ep[key] = params[key];
|
|
1157
|
-
}
|
|
1158
|
-
}
|
|
1159
|
-
|
|
1160
|
-
var origPaddingTop = ep.paddingtop;
|
|
1161
|
-
var origPaddingBottom = ep.paddingbottom;
|
|
1162
|
-
var currentScrollY = div.parentNode.scrollTop; // If there is scrolling it will be lost during the redraw so remember it.
|
|
1163
|
-
|
|
1164
|
-
var currentScrollX = div.parentNode.scrollLeft;
|
|
1165
|
-
div.innerHTML = "";
|
|
1166
|
-
var lineCount = 0;
|
|
1167
|
-
|
|
1168
|
-
for (var k = 0; k < tunes.length; k++) {
|
|
1169
|
-
var lineEl = document.createElement("div");
|
|
1170
|
-
div.appendChild(lineEl);
|
|
1171
|
-
|
|
1172
|
-
if (k === 0) {
|
|
1173
|
-
ep.paddingtop = origPaddingTop;
|
|
1174
|
-
ep.paddingbottom = 0;
|
|
1175
|
-
} else if (k === tunes.length - 1) {
|
|
1176
|
-
ep.paddingtop = 10;
|
|
1177
|
-
ep.paddingbottom = origPaddingBottom;
|
|
1178
|
-
} else {
|
|
1179
|
-
ep.paddingtop = 10;
|
|
1180
|
-
ep.paddingbottom = 0;
|
|
1181
|
-
}
|
|
1182
|
-
|
|
1183
|
-
if (k < tunes.length - 1) {
|
|
1184
|
-
// If it is not the last line, force stretchlast. If it is, stretchlast might have been set by the input parameters.
|
|
1185
|
-
tunes[k].formatting = parseCommon.clone(tunes[k].formatting);
|
|
1186
|
-
tunes[k].formatting.stretchlast = true;
|
|
1187
|
-
}
|
|
1188
|
-
|
|
1189
|
-
renderOne(lineEl, tunes[k], ep, tuneNumber, lineCount);
|
|
1190
|
-
lineCount += tunes[k].lines.length;
|
|
1191
|
-
if (k === 0) tune.engraver = tunes[k].engraver;else {
|
|
1192
|
-
if (!tune.engraver.staffgroups) tune.engraver.staffgroups = tunes[k].engraver.staffgroups;else if (tunes[k].engraver.staffgroups.length > 0) tune.engraver.staffgroups.push(tunes[k].engraver.staffgroups[0]);
|
|
1193
|
-
}
|
|
1194
|
-
}
|
|
1195
|
-
|
|
1196
|
-
if (currentScrollX || currentScrollY) {
|
|
1197
|
-
div.parentNode.scrollTo(currentScrollX, currentScrollY);
|
|
1198
|
-
}
|
|
1199
1104
|
} // A quick way to render a tune from javascript when interactivity is not required.
|
|
1200
1105
|
// This is used when a javascript routine has some abc text that it wants to render
|
|
1201
1106
|
// in a div or collection of divs. One tune or many can be rendered.
|
|
@@ -1266,8 +1171,9 @@ var renderAbc = function renderAbc(output, abc, parserParams, engraverParams, re
|
|
|
1266
1171
|
if (!removeDiv && params.wrap && params.staffwidth) {
|
|
1267
1172
|
tune = doLineWrapping(div, tune, tuneNumber, abcString, params);
|
|
1268
1173
|
return tune;
|
|
1269
|
-
}
|
|
1174
|
+
}
|
|
1270
1175
|
|
|
1176
|
+
renderOne(div, tune, params, tuneNumber, 0);
|
|
1271
1177
|
if (removeDiv) div.parentNode.removeChild(div);
|
|
1272
1178
|
return null;
|
|
1273
1179
|
}
|
|
@@ -1288,7 +1194,7 @@ function doLineWrapping(div, tune, tuneNumber, abcString, params) {
|
|
|
1288
1194
|
if (warnings) tune.warnings = warnings;
|
|
1289
1195
|
}
|
|
1290
1196
|
|
|
1291
|
-
|
|
1197
|
+
renderOne(div, tune, ret.revisedParams, tuneNumber, 0);
|
|
1292
1198
|
tune.explanation = ret.explanation;
|
|
1293
1199
|
return tune;
|
|
1294
1200
|
}
|
|
@@ -21992,6 +21898,7 @@ var tablatures = __webpack_require__(/*! ../api/abc_tablatures */ "./src/api/abc
|
|
|
21992
21898
|
|
|
21993
21899
|
var EngraverController = function EngraverController(paper, params) {
|
|
21994
21900
|
params = params || {};
|
|
21901
|
+
this.oneSvgPerLine = params.oneSvgPerLine;
|
|
21995
21902
|
this.selectionColor = params.selectionColor;
|
|
21996
21903
|
this.dragColor = params.dragColor ? params.dragColor : params.selectionColor;
|
|
21997
21904
|
this.dragging = !!params.dragging;
|
|
@@ -22208,8 +22115,78 @@ EngraverController.prototype.engraveTune = function (abcTune, tuneNumber, lineOf
|
|
|
22208
22115
|
var ret = draw(this.renderer, this.classes, abcTune, this.width, maxWidth, this.responsive, scale, this.selectTypes, tuneNumber, lineOffset);
|
|
22209
22116
|
this.staffgroups = ret.staffgroups;
|
|
22210
22117
|
this.selectables = ret.selectables;
|
|
22211
|
-
|
|
22212
|
-
|
|
22118
|
+
|
|
22119
|
+
if (this.oneSvgPerLine) {
|
|
22120
|
+
var div = this.renderer.paper.svg.parentNode;
|
|
22121
|
+
this.svgs = splitSvgIntoLines(div, abcTune.metaText.title);
|
|
22122
|
+
} else {
|
|
22123
|
+
this.svgs = [this.renderer.paper.svg];
|
|
22124
|
+
}
|
|
22125
|
+
|
|
22126
|
+
setupSelection(this, this.svgs);
|
|
22127
|
+
};
|
|
22128
|
+
|
|
22129
|
+
function splitSvgIntoLines(output, title) {
|
|
22130
|
+
// Each line is a top level <g> in the svg. To split it into separate
|
|
22131
|
+
// svgs iterate through each of those and put them in a new svg. Since
|
|
22132
|
+
// they are placed absolutely, the viewBox needs to be manipulated to
|
|
22133
|
+
// get the correct vertical positioning.
|
|
22134
|
+
// We copy all the attributes from the original svg except for the aria-label
|
|
22135
|
+
// since we want that to include a count. And the height is now a fraction of the original svg.
|
|
22136
|
+
if (!title) title = "Untitled";
|
|
22137
|
+
var source = output.querySelector("svg");
|
|
22138
|
+
var style = source.querySelector("style");
|
|
22139
|
+
var width = source.getAttribute("width");
|
|
22140
|
+
var sections = output.querySelectorAll("svg > g"); // each section is a line, or the top matter or the bottom matter, or text that has been inserted.
|
|
22141
|
+
|
|
22142
|
+
var nextTop = 0; // There are often gaps between the elements for spacing, so the actual top and height needs to be inferred.
|
|
22143
|
+
|
|
22144
|
+
var wrappers = []; // Create all the elements and place them at once because we use the current svg to get data. It would disappear after placing the first line.
|
|
22145
|
+
|
|
22146
|
+
var svgs = [];
|
|
22147
|
+
|
|
22148
|
+
for (var i = 0; i < sections.length; i++) {
|
|
22149
|
+
var section = sections[i];
|
|
22150
|
+
var box = section.getBBox();
|
|
22151
|
+
var gapBetweenLines = box.y - nextTop; // take the margin into account
|
|
22152
|
+
|
|
22153
|
+
var height = box.height + gapBetweenLines;
|
|
22154
|
+
var wrapper = document.createElement("div");
|
|
22155
|
+
wrapper.setAttribute("style", "overflow: hidden;height:" + height + "px;");
|
|
22156
|
+
var svg = duplicateSvg(source);
|
|
22157
|
+
var fullTitle = "Sheet Music for \"" + title + "\" section " + (i + 1);
|
|
22158
|
+
svg.setAttribute("aria-label", fullTitle);
|
|
22159
|
+
svg.setAttribute("height", height);
|
|
22160
|
+
svg.setAttribute("viewBox", "0 " + nextTop + " " + width + " " + height);
|
|
22161
|
+
svg.appendChild(style.cloneNode(true));
|
|
22162
|
+
var titleEl = document.createElement("title");
|
|
22163
|
+
titleEl.innerText = fullTitle;
|
|
22164
|
+
svg.appendChild(titleEl);
|
|
22165
|
+
svg.appendChild(section);
|
|
22166
|
+
wrapper.appendChild(svg);
|
|
22167
|
+
svgs.push(svg);
|
|
22168
|
+
output.appendChild(wrapper); //wrappers.push(wrapper)
|
|
22169
|
+
|
|
22170
|
+
nextTop = box.y + box.height;
|
|
22171
|
+
} // for (i = 0; i < wrappers.length; i++)
|
|
22172
|
+
// output.appendChild(wrappers[i])
|
|
22173
|
+
|
|
22174
|
+
|
|
22175
|
+
output.removeChild(source);
|
|
22176
|
+
return svgs;
|
|
22177
|
+
}
|
|
22178
|
+
|
|
22179
|
+
function duplicateSvg(source) {
|
|
22180
|
+
var svgNS = "http://www.w3.org/2000/svg";
|
|
22181
|
+
var svg = document.createElementNS(svgNS, "svg");
|
|
22182
|
+
|
|
22183
|
+
for (var i = 0; i < source.attributes.length; i++) {
|
|
22184
|
+
var attr = source.attributes[i];
|
|
22185
|
+
if (attr.name !== "height" && attr.name != "aria-label") svg.setAttribute(attr.name, attr.value);
|
|
22186
|
+
}
|
|
22187
|
+
|
|
22188
|
+
return svg;
|
|
22189
|
+
}
|
|
22213
22190
|
|
|
22214
22191
|
EngraverController.prototype.getDim = function (historyEl) {
|
|
22215
22192
|
// Get the dimensions on demand because the getBBox call is expensive.
|
|
@@ -24576,8 +24553,10 @@ var Selectables = __webpack_require__(/*! ./selectables */ "./src/write/draw/sel
|
|
|
24576
24553
|
|
|
24577
24554
|
function draw(renderer, classes, abcTune, width, maxWidth, responsive, scale, selectTypes, tuneNumber, lineOffset) {
|
|
24578
24555
|
var selectables = new Selectables(renderer.paper, selectTypes, tuneNumber);
|
|
24556
|
+
renderer.paper.openGroup();
|
|
24579
24557
|
renderer.moveY(renderer.padding.top);
|
|
24580
24558
|
nonMusic(renderer, abcTune.topText, selectables);
|
|
24559
|
+
renderer.paper.closeGroup();
|
|
24581
24560
|
renderer.moveY(renderer.spacing.music);
|
|
24582
24561
|
var staffgroups = [];
|
|
24583
24562
|
|
|
@@ -24586,6 +24565,8 @@ function draw(renderer, classes, abcTune, width, maxWidth, responsive, scale, se
|
|
|
24586
24565
|
var abcLine = abcTune.lines[line];
|
|
24587
24566
|
|
|
24588
24567
|
if (abcLine.staff) {
|
|
24568
|
+
renderer.paper.openGroup();
|
|
24569
|
+
|
|
24589
24570
|
if (abcLine.vskip) {
|
|
24590
24571
|
renderer.moveY(abcLine.vskip);
|
|
24591
24572
|
}
|
|
@@ -24595,17 +24576,22 @@ function draw(renderer, classes, abcTune, width, maxWidth, responsive, scale, se
|
|
|
24595
24576
|
staffgroup.line = lineOffset + line; // If there are non-music lines then the staffgroup array won't line up with the line array, so this keeps track.
|
|
24596
24577
|
|
|
24597
24578
|
staffgroups.push(staffgroup);
|
|
24579
|
+
renderer.paper.closeGroup();
|
|
24598
24580
|
} else if (abcLine.nonMusic) {
|
|
24581
|
+
renderer.paper.openGroup();
|
|
24599
24582
|
nonMusic(renderer, abcLine.nonMusic, selectables);
|
|
24583
|
+
renderer.paper.closeGroup();
|
|
24600
24584
|
}
|
|
24601
24585
|
}
|
|
24602
24586
|
|
|
24603
24587
|
classes.reset();
|
|
24604
24588
|
|
|
24605
24589
|
if (abcTune.bottomText && abcTune.bottomText.rows && abcTune.bottomText.rows.length > 0) {
|
|
24590
|
+
renderer.paper.openGroup();
|
|
24606
24591
|
renderer.moveY(24); // TODO-PER: Empirically discovered. What variable should this be?
|
|
24607
24592
|
|
|
24608
24593
|
nonMusic(renderer, abcTune.bottomText, selectables);
|
|
24594
|
+
renderer.paper.closeGroup();
|
|
24609
24595
|
}
|
|
24610
24596
|
|
|
24611
24597
|
setPaperSize(renderer, maxWidth, scale, responsive);
|
|
@@ -25672,8 +25658,8 @@ function drawStaffGroup(renderer, params, selectables, lineNumber) {
|
|
|
25672
25658
|
// renderer.y will be offset at the beginning of each staff by the amount required to make the relative pitch work.
|
|
25673
25659
|
// If there are multiple staves, then renderer.y will be incremented for each new staff.
|
|
25674
25660
|
var colorIndex; // An invisible marker is useful to be able to find where each system starts.
|
|
25661
|
+
//addInvisibleMarker(renderer, "abcjs-top-of-system");
|
|
25675
25662
|
|
|
25676
|
-
addInvisibleMarker(renderer, "abcjs-top-of-system");
|
|
25677
25663
|
var startY = renderer.y; // So that it can be restored after we're done.
|
|
25678
25664
|
// Set the absolute Y position for each staff here, so the voice drawing below can just use if.
|
|
25679
25665
|
|
|
@@ -25865,20 +25851,11 @@ function printBrace(renderer, absoluteY, brace, index, selectables) {
|
|
|
25865
25851
|
}
|
|
25866
25852
|
}
|
|
25867
25853
|
}
|
|
25868
|
-
}
|
|
25854
|
+
} // function addInvisibleMarker(renderer, className) {
|
|
25855
|
+
// var y = Math.round(renderer.y);
|
|
25856
|
+
// renderer.paper.pathToBack({path:"M 0 " + y + " L 0 0", stroke:"none", fill:"none", "stroke-opacity": 0, "fill-opacity": 0, 'class': renderer.controller.classes.generate(className), 'data-vertical': y });
|
|
25857
|
+
// }
|
|
25869
25858
|
|
|
25870
|
-
function addInvisibleMarker(renderer, className) {
|
|
25871
|
-
var y = Math.round(renderer.y);
|
|
25872
|
-
renderer.paper.pathToBack({
|
|
25873
|
-
path: "M 0 " + y + " L 0 0",
|
|
25874
|
-
stroke: "none",
|
|
25875
|
-
fill: "none",
|
|
25876
|
-
"stroke-opacity": 0,
|
|
25877
|
-
"fill-opacity": 0,
|
|
25878
|
-
'class': renderer.controller.classes.generate(className),
|
|
25879
|
-
'data-vertical': y
|
|
25880
|
-
});
|
|
25881
|
-
}
|
|
25882
25859
|
|
|
25883
25860
|
function boxAllElements(renderer, voices, which) {
|
|
25884
25861
|
for (var i = 0; i < which.length; i++) {
|
|
@@ -28045,7 +28022,7 @@ module.exports = layoutVoice;
|
|
|
28045
28022
|
|
|
28046
28023
|
var spacing = __webpack_require__(/*! ./abc_spacing */ "./src/write/abc_spacing.js");
|
|
28047
28024
|
|
|
28048
|
-
function setupSelection(engraver) {
|
|
28025
|
+
function setupSelection(engraver, svgs) {
|
|
28049
28026
|
engraver.rangeHighlight = rangeHighlight;
|
|
28050
28027
|
|
|
28051
28028
|
if (engraver.dragging) {
|
|
@@ -28062,14 +28039,21 @@ function setupSelection(engraver) {
|
|
|
28062
28039
|
}
|
|
28063
28040
|
}
|
|
28064
28041
|
|
|
28065
|
-
|
|
28066
|
-
|
|
28067
|
-
|
|
28042
|
+
for (var i = 0; i < svgs.length; i++) {
|
|
28043
|
+
svgs[i].addEventListener('touchstart', mouseDown.bind(engraver));
|
|
28044
|
+
svgs[i].addEventListener('touchmove', mouseMove.bind(engraver));
|
|
28045
|
+
svgs[i].addEventListener('touchend', mouseUp.bind(engraver));
|
|
28046
|
+
svgs[i].addEventListener('mousedown', mouseDown.bind(engraver));
|
|
28047
|
+
svgs[i].addEventListener('mousemove', mouseMove.bind(engraver));
|
|
28048
|
+
svgs[i].addEventListener('mouseup', mouseUp.bind(engraver));
|
|
28049
|
+
}
|
|
28068
28050
|
}
|
|
28069
28051
|
|
|
28070
|
-
function getCoord(ev
|
|
28052
|
+
function getCoord(ev) {
|
|
28071
28053
|
var scaleX = 1;
|
|
28072
|
-
var scaleY = 1;
|
|
28054
|
+
var scaleY = 1;
|
|
28055
|
+
var svg = ev.target.closest('svg');
|
|
28056
|
+
var yOffset = 0; // when renderer.options.responsive === 'resize' the click coords are in relation to the HTML
|
|
28073
28057
|
// element, we need to convert to the SVG viewBox coords
|
|
28074
28058
|
|
|
28075
28059
|
if (svg.viewBox.baseVal) {
|
|
@@ -28077,6 +28061,7 @@ function getCoord(ev, svg) {
|
|
|
28077
28061
|
// Chrome makes these values null when no viewBox is given.
|
|
28078
28062
|
if (svg.viewBox.baseVal.width !== 0) scaleX = svg.viewBox.baseVal.width / svg.clientWidth;
|
|
28079
28063
|
if (svg.viewBox.baseVal.height !== 0) scaleY = svg.viewBox.baseVal.height / svg.clientHeight;
|
|
28064
|
+
yOffset = svg.viewBox.baseVal.y;
|
|
28080
28065
|
}
|
|
28081
28066
|
|
|
28082
28067
|
var svgClicked = ev.target.tagName === "svg";
|
|
@@ -28094,7 +28079,7 @@ function getCoord(ev, svg) {
|
|
|
28094
28079
|
x = x * scaleX;
|
|
28095
28080
|
y = y * scaleY; //console.log(x, y)
|
|
28096
28081
|
|
|
28097
|
-
return [x, y];
|
|
28082
|
+
return [x, y + yOffset];
|
|
28098
28083
|
}
|
|
28099
28084
|
|
|
28100
28085
|
function elementFocused(ev) {
|
|
@@ -28175,7 +28160,7 @@ function keyboardSelection(ev) {
|
|
|
28175
28160
|
|
|
28176
28161
|
function findElementInHistory(selectables, el) {
|
|
28177
28162
|
for (var i = 0; i < selectables.length; i++) {
|
|
28178
|
-
if (el === selectables[i].svgEl) return i;
|
|
28163
|
+
if (el.dataset.index === selectables[i].svgEl.dataset.index) return i;
|
|
28179
28164
|
}
|
|
28180
28165
|
|
|
28181
28166
|
return -1;
|
|
@@ -28268,7 +28253,7 @@ function getMousePosition(self, ev) {
|
|
|
28268
28253
|
y = box[1]; //console.log("clicked on", clickedOn, x, y, self.selectables[clickedOn].svgEl.getBBox(), ev.target.getBBox());
|
|
28269
28254
|
} else {
|
|
28270
28255
|
// See if they clicked close to an element.
|
|
28271
|
-
box = getCoord(ev
|
|
28256
|
+
box = getCoord(ev);
|
|
28272
28257
|
x = box[0];
|
|
28273
28258
|
y = box[1];
|
|
28274
28259
|
clickedOn = findElementByCoord(self, x, y); //console.log("clicked near", clickedOn, x, y, printEl(ev.target));
|
|
@@ -28281,11 +28266,28 @@ function getMousePosition(self, ev) {
|
|
|
28281
28266
|
};
|
|
28282
28267
|
}
|
|
28283
28268
|
|
|
28269
|
+
function attachMissingTouchEventAttributes(touchEv) {
|
|
28270
|
+
var rect = touchEv.target.getBoundingClientRect();
|
|
28271
|
+
var offsetX = touchEv.touches[0].pageX - rect.left;
|
|
28272
|
+
var offsetY = touchEv.touches[0].pageY - rect.top;
|
|
28273
|
+
touchEv.touches[0].offsetX = offsetX;
|
|
28274
|
+
touchEv.touches[0].offsetY = offsetY;
|
|
28275
|
+
touchEv.touches[0].layerX = touchEv.touches[0].pageX;
|
|
28276
|
+
touchEv.touches[0].layerY = touchEv.touches[0].pageY;
|
|
28277
|
+
}
|
|
28278
|
+
|
|
28284
28279
|
function mouseDown(ev) {
|
|
28285
28280
|
// "this" is the EngraverController because of the bind(this) when setting the event listener.
|
|
28286
|
-
var
|
|
28281
|
+
var _ev = ev;
|
|
28282
|
+
|
|
28283
|
+
if (ev.type === 'touchstart') {
|
|
28284
|
+
attachMissingTouchEventAttributes(ev);
|
|
28285
|
+
_ev = ev.touches[0];
|
|
28286
|
+
}
|
|
28287
|
+
|
|
28288
|
+
var positioning = getMousePosition(this, _ev); // Only start dragging if the user clicked close enough to an element and clicked with the main mouse button.
|
|
28287
28289
|
|
|
28288
|
-
if (positioning.clickedOn >= 0 && ev.button === 0) {
|
|
28290
|
+
if (positioning.clickedOn >= 0 && (ev.type === 'touchstart' || ev.button === 0)) {
|
|
28289
28291
|
this.dragTarget = this.selectables[positioning.clickedOn];
|
|
28290
28292
|
this.dragIndex = positioning.clickedOn;
|
|
28291
28293
|
this.dragMechanism = "mouse";
|
|
@@ -28302,9 +28304,17 @@ function mouseDown(ev) {
|
|
|
28302
28304
|
}
|
|
28303
28305
|
|
|
28304
28306
|
function mouseMove(ev) {
|
|
28305
|
-
|
|
28307
|
+
var _ev = ev;
|
|
28308
|
+
|
|
28309
|
+
if (ev.type === 'touchmove') {
|
|
28310
|
+
attachMissingTouchEventAttributes(ev);
|
|
28311
|
+
_ev = ev.touches[0];
|
|
28312
|
+
}
|
|
28313
|
+
|
|
28314
|
+
this.lastTouchMove = ev; // "this" is the EngraverController because of the bind(this) when setting the event listener.
|
|
28315
|
+
|
|
28306
28316
|
if (!this.dragTarget || !this.dragging || !this.dragTarget.isDraggable || this.dragMechanism !== 'mouse') return;
|
|
28307
|
-
var positioning = getMousePosition(this,
|
|
28317
|
+
var positioning = getMousePosition(this, _ev);
|
|
28308
28318
|
var yDist = Math.round((positioning.y - this.dragMouseStart.y) / spacing.STEP);
|
|
28309
28319
|
|
|
28310
28320
|
if (yDist !== this.dragYStep) {
|
|
@@ -28315,6 +28325,13 @@ function mouseMove(ev) {
|
|
|
28315
28325
|
|
|
28316
28326
|
function mouseUp(ev) {
|
|
28317
28327
|
// "this" is the EngraverController because of the bind(this) when setting the event listener.
|
|
28328
|
+
var _ev = ev;
|
|
28329
|
+
|
|
28330
|
+
if (ev.type === 'touchend') {
|
|
28331
|
+
attachMissingTouchEventAttributes(this.lastTouchMove);
|
|
28332
|
+
_ev = this.lastTouchMove.touches[0];
|
|
28333
|
+
}
|
|
28334
|
+
|
|
28318
28335
|
if (!this.dragTarget) return;
|
|
28319
28336
|
clearSelection.bind(this)();
|
|
28320
28337
|
|
|
@@ -28323,7 +28340,7 @@ function mouseUp(ev) {
|
|
|
28323
28340
|
this.dragTarget.absEl.highlight(undefined, this.selectionColor);
|
|
28324
28341
|
}
|
|
28325
28342
|
|
|
28326
|
-
notifySelect.bind(this)(this.dragTarget, this.dragYStep, this.selectables.length, this.dragIndex,
|
|
28343
|
+
notifySelect.bind(this)(this.dragTarget, this.dragYStep, this.selectables.length, this.dragIndex, _ev);
|
|
28327
28344
|
|
|
28328
28345
|
if (this.dragTarget.svgEl && this.dragTarget.svgEl.focus) {
|
|
28329
28346
|
this.dragTarget.svgEl.focus();
|
|
@@ -29130,7 +29147,7 @@ module.exports = unhighlight;
|
|
|
29130
29147
|
\********************/
|
|
29131
29148
|
/***/ (function(module) {
|
|
29132
29149
|
|
|
29133
|
-
var version = '6.1.
|
|
29150
|
+
var version = '6.1.1';
|
|
29134
29151
|
module.exports = version;
|
|
29135
29152
|
|
|
29136
29153
|
/***/ })
|