Skip to content

Instantly share code, notes, and snippets.

@xoor-io
Created April 26, 2018 19:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save xoor-io/a92022652e91e2471a4960f172fa422d to your computer and use it in GitHub Desktop.
Save xoor-io/a92022652e91e2471a4960f172fa422d to your computer and use it in GitHub Desktop.
d3-canvas-brush-zoom-06
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