Skip to content

Commit fb2d173

Browse files
committed
Improve the handling of the connection order
1 parent 9a18c5d commit fb2d173

3 files changed

Lines changed: 10 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
## Next
22

3+
**Breaking changes:**
4+
5+
- Improve the handling of the connection order by switching from a structured 5th component to a 6th component.
6+
7+
Previously to provide a specific order, the 5th component had to be a tuple of `[lineComponentId, orderIndex]`. With this update the 5th component will always just be `lineComponentId` and the 6th will be `orderIndex`.
8+
39
## v0.18.7
410

511
- Avoid text selection when lassoing

example/connected-points.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ const generatePoints = (num) => {
8585
g, // category
8686
Math.random(), // value
8787
g * numPointsPerStep + i, // to identify connected points
88+
// (s + 2) % 5, // specifies the order of the connected points
8889
]);
8990
}
9091
}

src/spline-curve-worker.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,13 @@ const worker = function worker() {
210210
const groupPoints = (points) => {
211211
const groupedPoints = {};
212212

213+
const isOrdered = !Number.isNaN(+points[0][5]);
213214
points.forEach((point) => {
214-
const isStruct = Array.isArray(point[4]);
215-
const segId = isStruct ? point[4][0] : point[4];
215+
const segId = point[4];
216216

217217
if (!groupedPoints[segId]) groupedPoints[segId] = [];
218218

219-
if (isStruct) groupedPoints[segId][point[4][1]] = point;
219+
if (isOrdered) groupedPoints[segId][point[5]] = point;
220220
else groupedPoints[segId].push(point);
221221
});
222222

0 commit comments

Comments
 (0)