Created
April 26, 2018 19:24
-
-
Save xoor-io/a92022652e91e2471a4960f172fa422d to your computer and use it in GitHub Desktop.
d3-canvas-brush-zoom-06
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
function brush_brushEvent() { | |
if (brushStartPoint !== null) { | |
const scale = width / height; | |
const sourceEvent = d3.event.sourceEvent; | |
const mouse = { | |
x: sourceEvent.screenX, | |
y: sourceEvent.screenY | |
}; | |
if (mouse.x < 0) { mouse.x = 0; } | |
if (mouse.y < 0) { mouse.y = 0; } | |
let distance = mouse.y - brushStartPoint.mouse.y; | |
let yPosition = brushStartPoint.y + distance; | |
let xCorMulti = 1; | |
if ((distance < 0 && mouse.x > brushStartPoint.mouse.x) || (distance > 0 && mouse.x < brushStartPoint.mouse.x)) { | |
xCorMulti = -1; | |
} | |
... | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment