Skip to content

Commit 05c1c85

Browse files
committed
pass in distance as the third argument
1 parent 803d5a7 commit 05c1c85

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/traces/bar/hover.js

+4-11
Original file line numberDiff line numberDiff line change
@@ -62,26 +62,19 @@ function hoverOnBars(pointData, xval, yval, hovermode) {
6262
return Math.max(thisBarMaxPos(di), di.p + t.bardelta / 2);
6363
};
6464

65-
function hoverPositionFn(_minPos, _maxPos) {
65+
function inbox(_minPos, _maxPos, maxDistance) {
6666
// add a little to the pseudo-distance for wider bars, so that like scatter,
6767
// if you are over two overlapping bars, the narrower one wins.
6868
return Fx.inbox(_minPos - posVal, _maxPos - posVal,
69-
maxHoverDistance + Math.min(1, Math.abs(_maxPos - _minPos) / pRangeCalc) - 1);
70-
}
71-
72-
function spikePositionFn(_minPos, _maxPos) {
73-
// add a little to the pseudo-distance for wider bars, so that like scatter,
74-
// if you are over two overlapping bars, the narrower one wins.
75-
return Fx.inbox(_minPos - posVal, _maxPos - posVal,
76-
maxSpikeDistance + Math.min(1, Math.abs(_maxPos - _minPos) / pRangeCalc) - 1);
69+
maxDistance + Math.min(1, Math.abs(_maxPos - _minPos) / pRangeCalc) - 1);
7770
}
7871

7972
function positionFn(di) {
80-
return hoverPositionFn(minPos(di), maxPos(di));
73+
return inbox(minPos(di), maxPos(di), maxHoverDistance);
8174
}
8275

8376
function thisBarPositionFn(di) {
84-
return spikePositionFn(thisBarMinPos(di), thisBarMaxPos(di));
77+
return inbox(thisBarMinPos(di), thisBarMaxPos(di), maxSpikeDistance);
8578
}
8679

8780
function getSize(di) {

0 commit comments

Comments
 (0)