Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/scale.types.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,18 @@ function zoomDelta(scale, zoom, center) {
const newRange = range * (zoom - 1);

const centerPoint = scale.isHorizontal() ? center.x : center.y;
const minPercent = (scale.getValueForPixel(centerPoint) - scale.min) / range || 0;
// `scale.getValueForPixel()` can return a value
// less than the minimum value
// and greater than the maximum value
// when `centerPoint` is past the minimum/maximum values
// (e.g., on the y-axis labels).
const minPercent = Math.max(
0,
Math.min(
1,
(scale.getValueForPixel(centerPoint) - scale.min) / range || 0
)
);
const maxPercent = 1 - minPercent;

return {
Expand Down