Skip to content

Commit

Permalink
Merge pull request #1124 from erick2014/fix/issue-1095
Browse files Browse the repository at this point in the history
Change cursor when allowResize and allowDrag are false
  • Loading branch information
boygirl authored Sep 26, 2018
2 parents 5156138 + f1fdd8b commit e960f09
Showing 1 changed file with 22 additions and 3 deletions.
25 changes: 22 additions & 3 deletions packages/victory-brush-container/src/victory-brush-container.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,27 +83,46 @@ export const brushContainerMixin = (base) => class VictoryBrushContainer extends
const { x, y } = coordinates;
const { brushStyle, brushComponent, name } = props;
const brushComponentStyle = brushComponent.props && brushComponent.props.style;
const cursor = !props.allowDrag && !props.allowResize ? "auto" : "move";
return x[0] !== x[1] && y[0] !== y[1] ?
React.cloneElement(brushComponent, {
key: `${name}-brush`,
width: Math.abs(x[1] - x[0]) || 1,
height: Math.abs(y[1] - y[0]) || 1,
x: Math.min(x[0], x[1]),
y: Math.min(y[0], y[1]),
cursor: "move",
cursor,
style: defaults({}, brushComponentStyle, brushStyle)
}) : null;
}

getCursorPointers(props) {
const cursors = {
"yProps": "ns-resize",
"xProps": "ew-resize"
};
if (!props.allowResize && props.allowDrag) {
cursors.xProps = "move";
cursors.yProps = "move";
} else if (!props.allowResize && !props.allowDrag) {
cursors.xProps = "auto";
cursors.yProps = "auto";
}
return cursors;
}

getHandles(props, coordinates) {
const { brushDimension, handleWidth, handleStyle, handleComponent, name } = props;
const { x, y } = coordinates;
const width = Math.abs(x[1] - x[0]) || 1;
const height = Math.abs(y[1] - y[0]) || 1;
const handleComponentStyle = handleComponent.props && handleComponent.props.style || {};
const style = defaults({}, handleComponentStyle, handleStyle);
const yProps = { style, width, height: handleWidth, cursor: "ns-resize" };
const xProps = { style, width: handleWidth, height, cursor: "ew-resize" };

const cursors = this.getCursorPointers(props);
const yProps = { style, width, height: handleWidth, cursor: cursors.yProps };
const xProps = { style, width: handleWidth, height, cursor: cursors.xProps };

const handleProps = {
top: brushDimension !== "x" && assign({ x: x[0], y: y[1] - (handleWidth / 2) }, yProps),
bottom: brushDimension !== "x" && assign({ x: x[0], y: y[0] - (handleWidth / 2) }, yProps),
Expand Down

0 comments on commit e960f09

Please sign in to comment.