Skip to content

Commit 7d1b4a9

Browse files
committed
Fix another issue with blurring point connections
1 parent 9e4750d commit 7d1b4a9

1 file changed

Lines changed: 29 additions & 18 deletions

File tree

src/index.js

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ const createScatterplot = (initialProperties = {}) => {
242242
let mouseDown = false;
243243
let selection = [];
244244
const selectionSet = new Set();
245+
const selectionConnecionSet = new Set();
245246
let mouseDownTime = null;
246247
let mouseDownPosition = [0, 0];
247248
let numPoints = 0;
@@ -511,6 +512,10 @@ const createScatterplot = (initialProperties = {}) => {
511512
return;
512513

513514
const isNormal = stateIndex === 0;
515+
const lineIdCacher =
516+
stateIndex === 1
517+
? (lineId) => selectionConnecionSet.add(lineId)
518+
: identity;
514519

515520
// Get line IDs
516521
const lineIds = Object.keys(
@@ -527,28 +532,32 @@ const createScatterplot = (initialProperties = {}) => {
527532

528533
const buffer = pointConnections.getData().opacities;
529534

530-
lineIds.forEach((lineId) => {
531-
const index = pointConnectionMap[lineId][0];
532-
const numPointPerLine = pointConnectionMap[lineId][2];
533-
const pointOffset = pointConnectionMap[lineId][3];
535+
lineIds
536+
.filter((lineId) => !selectionConnecionSet.has(+lineId))
537+
.forEach((lineId) => {
538+
const index = pointConnectionMap[lineId][0];
539+
const numPointPerLine = pointConnectionMap[lineId][2];
540+
const pointOffset = pointConnectionMap[lineId][3];
534541

535-
const bufferStart = index * 4 + pointOffset * 2;
536-
const bufferEnd = bufferStart + numPointPerLine * 2 + 4;
542+
const bufferStart = index * 4 + pointOffset * 2;
543+
const bufferEnd = bufferStart + numPointPerLine * 2 + 4;
537544

538-
// eslint-disable-next-line no-underscore-dangle
539-
if (buffer.__original__ === undefined) {
540545
// eslint-disable-next-line no-underscore-dangle
541-
buffer.__original__ = buffer.slice();
542-
}
546+
if (buffer.__original__ === undefined) {
547+
// eslint-disable-next-line no-underscore-dangle
548+
buffer.__original__ = buffer.slice();
549+
}
543550

544-
for (let i = bufferStart; i < bufferEnd; i++) {
545-
// buffer[i] = Math.floor(buffer[i] / 4) * 4 + stateIndex;
546-
buffer[i] = isNormal
547-
? // eslint-disable-next-line no-underscore-dangle
548-
buffer.__original__[i]
549-
: pointConnectionOpacityActive;
550-
}
551-
});
551+
for (let i = bufferStart; i < bufferEnd; i++) {
552+
// buffer[i] = Math.floor(buffer[i] / 4) * 4 + stateIndex;
553+
buffer[i] = isNormal
554+
? // eslint-disable-next-line no-underscore-dangle
555+
buffer.__original__[i]
556+
: pointConnectionOpacityActive;
557+
}
558+
559+
lineIdCacher(lineId);
560+
});
552561

553562
pointConnections.getBuffer().opacities.subdata(buffer, 0);
554563
};
@@ -562,6 +571,7 @@ const createScatterplot = (initialProperties = {}) => {
562571
if (lassoClearEvent === LASSO_CLEAR_ON_DESELECT) lassoClear();
563572
if (selection.length) {
564573
if (!preventEvent) pubSub.publish('deselect');
574+
selectionConnecionSet.clear();
565575
setPointConnectionColorState(selection, 0);
566576
selection = [];
567577
selectionSet.clear();
@@ -582,6 +592,7 @@ const createScatterplot = (initialProperties = {}) => {
582592
const selectionBuffer = new Float32Array(selection.length * 2);
583593

584594
selectionSet.clear();
595+
selectionConnecionSet.clear();
585596
selection.forEach((pointIdx, i) => {
586597
selectionSet.add(pointIdx);
587598
const texCoords = indexToStateTexCoord(pointIdx);

0 commit comments

Comments
 (0)