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

Commit

Permalink
Merge pull request #278 from FormidableLabs/experiment/touch-events
Browse files Browse the repository at this point in the history
Experiment/touch events
  • Loading branch information
boygirl authored Aug 7, 2017
2 parents 7d3c98c + 03ec305 commit 72c2ac0
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/victory-container/victory-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ export default class VictoryContainer extends React.Component {
render() {
const { width, height, responsive, events } = this.props;
const style = responsive ? this.props.style : omit(this.props.style, ["height", "width"]);
const touchStyle = assign({}, style, { touchAction: "none" });
const svgProps = assign(
{
width, height, role: "img",
Expand All @@ -122,6 +123,6 @@ export default class VictoryContainer extends React.Component {
},
events
);
return this.renderContainer(this.props, svgProps, style);
return this.renderContainer(this.props, svgProps, touchStyle);
}
}
22 changes: 22 additions & 0 deletions src/victory-tooltip/victory-tooltip.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,17 @@ export default class VictoryTooltip extends React.Component {
}
];
},
onTouchStart: (targetProps) => {
return [
{
target: "labels",
mutation: () => ({ active: true })
}, {
target: "data",
mutation: () => targetProps.activateData ? ({ active: true }) : ({ active: undefined })
}
];
},
onMouseOut: () => {
return [
{
Expand All @@ -118,6 +129,17 @@ export default class VictoryTooltip extends React.Component {
mutation: () => ({ active: undefined })
}
];
},
onTouchEnd: () => {
return [
{
target: "labels",
mutation: () => ({ active: undefined })
}, {
target: "data",
mutation: () => ({ active: undefined })
}
];
}
}
}];
Expand Down
1 change: 1 addition & 0 deletions src/victory-util/selection.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default {
y: evt.nativeEvent.locationY
};
}
evt = evt.changedTouches && evt.changedTouches.length ? evt.changedTouches[0] : evt;
const svg = this.getParentSVG(evt.target);
const matrix = this.getTransformationMatrix(svg);
return {
Expand Down

0 comments on commit 72c2ac0

Please sign in to comment.