Created
May 11, 2018 15:06
-
-
Save xoor-io/d3fdae8aec1f97b2ff355f20e9c7469c to your computer and use it in GitHub Desktop.
d3-canvas-brush-zoom-08
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let xPosition = brushStartPoint.x + distance * scale * xCorMulti; | |
const oldDistance = distance; | |
if (xPosition > width) { | |
distance = (width - brushStartPoint.x) / scale; | |
xPosition = width; | |
} else if (xPosition < 0) { | |
distance = brushStartPoint.x / scale; | |
xPosition = 0; | |
} | |
if (oldDistance !== distance) { | |
distance *= (oldDistance < 0) ? -1 : 1; | |
yPosition = brushStartPoint.y + distance; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment