D3 v4: Reset zoom state

前端 未结 5 1810
谎友^
谎友^ 2021-02-19 07:26

I have a SVG which can be zoomed and also a \"reset\" button. I\'m resetting the zoom with

zoom.transform(selection, d3.zoomIdentity)

This wor

5条回答
  •  温柔的废话
    2021-02-19 08:18

    I meet the same problem using

    this.svg.selectAll('g').call(this.zoom.transform, d3.zoomIdentity.scale(1));
    

    and I change to

    this.svg.call(this.zoom.transform, d3.zoomIdentity.scale(1));
    

    soloved the problem.

    I think the _zoom will be stored in the svg level also.

提交回复
热议问题