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

Experiment/touch events #278

Merged
merged 3 commits into from
Aug 7, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/victory-container/victory-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,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 @@ -120,6 +121,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 @@ -107,6 +107,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 @@ -117,6 +128,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