Skip to content

Commit 3bdbedb

Browse files
committed
declare and reuse a variable for isClosest or period in bar hover
1 parent 21fa988 commit 3bdbedb

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

Diff for: src/traces/bar/hover.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
5252
}
5353

5454
var period = trace[posLetter + 'period'];
55+
var isClosestOrPeriod = isClosest || period;
5556

5657
function thisBarMinPos(di) { return thisBarExtPos(di, -1); }
5758
function thisBarMaxPos(di) { return thisBarExtPos(di, 1); }
@@ -62,7 +63,7 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
6263
return di[posLetter] + sgn * w / 2;
6364
}
6465

65-
var minPos = isClosest || period ?
66+
var minPos = isClosestOrPeriod ?
6667
thisBarMinPos :
6768
function(di) {
6869
/*
@@ -80,7 +81,7 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
8081
return Math.min(thisBarMinPos(di), di.p - t.bardelta / 2);
8182
};
8283

83-
var maxPos = isClosest || period ?
84+
var maxPos = isClosestOrPeriod ?
8485
thisBarMaxPos :
8586
function(di) {
8687
return Math.max(thisBarMaxPos(di), di.p + t.bardelta / 2);
@@ -156,7 +157,7 @@ function hoverOnBars(pointData, xval, yval, hovermode, opts) {
156157
// if we get here and we're not in 'closest' mode, push min/max pos back
157158
// onto the group - even though that means occasionally the mouse will be
158159
// over the hover label.
159-
if(!isClosest && !period) {
160+
if(!isClosestOrPeriod) {
160161
minPos = function(di) {
161162
return Math.min(thisBarMinPos(di), di.p - t.bargroupwidth / 2);
162163
};

0 commit comments

Comments
 (0)