d3 / d3-zoom

Pan and zoom SVG, HTML or Canvas using mouse or touch input.

Home Page:https://d3js.org/d3-zoom

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Zoom transform interrupts null transitions

magjac opened this issue · comments

Not 100% sure this is a bug or possibly intentional.

A zoom behavior attached to a selection that has an active transition without a name (i.e. null is used) interrupts the transition when translated by e.g. translateBy. If the transition is named, it is not interrupted.

I think this happens on https://github.com/d3/d3-zoom/blobymaster/src/zoom.js#L81. Should it just interrupt transitions named "zoom"?

This is the intended behavior. The only case where the zoom behavior initiates a transition on its own is in response to a dblclick event, and this transition has the null name. If you pass a selection to zoom.transform (or a wrapper method such as zoom.translateBy) it will likewise only interrupt transitions with the null name.

We could change the zoom behavior to use the name “zoom” in these two situations, but that would mean any programmatic zoom transitions would not be automatically interrupted by interaction. So, the null name was chosen to keep things simple.

Thanks for the clarification. I will apply the zoom behavior to a selection that will not have any transitions or use a named transition.