Skip to content

Commit 48b13cd

Browse files
committed
Harmonize hover() to allow preventing events
1 parent 75b0715 commit 48b13cd

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

CHANGELOG.md

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

3+
## v0.18.3
4+
5+
- Harmonize `hover(pointIdx, { showReticleOnce, preventEvent })` with `select()` API by allowing it to prevent the `pointover` and `pointout` from being published.
6+
37
## v0.18.2
48

59
- Add two events: `init` and `destroy`

src/index.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,7 +2600,10 @@ const createScatterplot = (initialProperties = {}) => {
26002600
);
26012601
};
26022602

2603-
const hover = (point, showReticleOnce = false) => {
2603+
const hover = (
2604+
point,
2605+
{ showReticleOnce = false, preventEvent = false } = {}
2606+
) => {
26042607
let needsRedraw = false;
26052608

26062609
if (point >= 0) {
@@ -2617,12 +2620,13 @@ const createScatterplot = (initialProperties = {}) => {
26172620
hoveredPoint = point;
26182621
hoveredPointIndexBuffer.subdata(indexToStateTexCoord(point));
26192622
if (!selectionSet.has(point)) setPointConnectionColorState([point], 2);
2620-
if (newHoveredPoint) pubSub.publish('pointover', hoveredPoint);
2623+
if (newHoveredPoint && !preventEvent)
2624+
pubSub.publish('pointover', hoveredPoint);
26212625
} else {
26222626
needsRedraw = +hoveredPoint >= 0;
26232627
if (needsRedraw && !selectionSet.has(hoveredPoint)) {
26242628
setPointConnectionColorState([hoveredPoint], 0);
2625-
pubSub.publish('pointout', hoveredPoint);
2629+
if (!preventEvent) pubSub.publish('pointout', hoveredPoint);
26262630
}
26272631
hoveredPoint = undefined;
26282632
}

0 commit comments

Comments
 (0)