Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Predefined events override manual transformations #248

Open
l0drex opened this issue Dec 13, 2021 · 0 comments
Open

Predefined events override manual transformations #248

l0drex opened this issue Dec 13, 2021 · 0 comments

Comments

@l0drex
Copy link

l0drex commented Dec 13, 2021

I have the following code:

let canvas = d3.select("#canvas")
let canvasTransform = d3.zoom()

canvas.call(canvasTransform.on("zoom", event => canvas.attr("transform", event.transform)

function scale(delta) {
    canvasTransform.scaleBy(canvas, delta, [focus.x, focus.y]
}

function move(dx, dy) {
    canvasTransform.translateBy(outer, dx, dy)
}

This works, but there is one problem: when I call one of the above functions and then use the mouse to zoom or translate, the manual transformation applied by the functions above are ignored. To me, it seems like they use completely different transformation states.

Am I doing something wrong, or is this a bug in d3-zoom?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant