Skip to content
This repository has been archived by the owner on Feb 19, 2022. It is now read-only.

Commit

Permalink
safety commit
Browse files Browse the repository at this point in the history
  • Loading branch information
boygirl committed Jan 19, 2017
1 parent c4be637 commit b75b01d
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/victory-container/victory-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ export default class VictoryContainer extends React.Component {

componentWillMount() {
this.savePortalRef = (portal) => this.portalRef = portal;
this.saveSvgRef = (svg) => this.svgRef = svg;
this.portalUpdate = (key, el) => this.portalRef.portalUpdate(key, el);
this.portalRegister = () => this.portalRef.portalRegister();
this.portalDeregister = (key) => this.portalRef.portalDeregister(key);
Expand Down Expand Up @@ -97,8 +96,7 @@ export default class VictoryContainer extends React.Component {
const svgProps = assign(
{
"aria-labelledby": "title desc", role: "img", width, height,
viewBox: responsive ? `0 0 ${width} ${height}` : undefined,
ref: this.saveSvgRef

This comment has been minimized.

Copy link
@omeid

omeid Aug 30, 2017

@boygirl Can you explain why this was removed please?

This comment has been minimized.

Copy link
@boygirl

boygirl Aug 30, 2017

Author Contributor

Yes. This commit was part of this pull request which supported the replacement of VictoryZoom with VictoryZoomContainer as described in release notes here. The svg ref that was removed was only used in VictoryChart and VictoryGroup in order to support the old, deprecated VictoryZoom wrapper. See corresponding removals here and here. You can see how VictoryZoom was originally using this ref here.

This comment has been minimized.

Copy link
@omeid

omeid Aug 30, 2017

Thanks. That helps.

viewBox: responsive ? `0 0 ${width} ${height}` : undefined
},
events
);
Expand Down
26 changes: 23 additions & 3 deletions src/victory-util/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,33 @@ export default {
}
},

getTransformationMatrix(svg) {
return svg.getScreenCTM().inverse();
},

getSVGEventCoordinates(evt) {
const svg = this.getParentSVG(evt.target);
const matrix = svg.getScreenCTM().inverse();
const matrix = this.getTransformationMatrix(svg);
return {
x: this.transformTarget(evt.clientX, matrix, "x"),
y: this.transformTarget(evt.clientY, matrix, "y")
};
},

transformTarget(target, matrix, dimension) {
const {a, d, e, f} = matrix;
return dimension === "y" ?
d * target + f : a * target + e;
},

getDomainCoordinates(scale) {
const domain = {
x: scale.x.domain(),
y: scale.y.domain()
};
return {
x: a * evt.clientX + e,
y: d * evt.clientY + f
x: [scale.x(domain.x[0]), scale.x(domain.x[1])],
y: [scale.y(domain.y[0]), scale.y(domain.y[1])]
};
},

Expand Down

0 comments on commit b75b01d

Please sign in to comment.