Open adam-s opened 6 years ago
Solved it. The zoomToPoint method is public and available through setting a ref on the parent.
constructor(props) {
super(props);
this.svgPanZoom = null;
this.setSvgPanZoom = (element) => {
this.svgPanZoom = element;
};
}
componentDidUpdate(prevProps) {
const { bounds } = this.props;
if (R.not(R.equals(prevProps.bounds, bounds))) {
this.svgPanZoom.zoomToPoint(100, 100, 1.2);
console.log('bound changed');
}
}
There is an unused method
public zoomToPoint = (x: number, y: number, scale: number, duration: number = 700)
. It would be nice to be able to pass an object that is updated from the parent component with the { x, y, zoom } so the element can be panned and zoomed automatically.