Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change cursor when allowResize and allowDrag are false #1124

Merged
merged 5 commits into from
Sep 26, 2018
Merged
Changes from 2 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
16 changes: 13 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,14 +83,15 @@ 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;
}
Expand All @@ -102,8 +103,17 @@ export const brushContainerMixin = (base) => class VictoryBrushContainer extends
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" };

let yProps = { style, width, height: handleWidth, cursor: "ns-resize" };
let xProps = { style, width: handleWidth, height, cursor: "ew-resize" };

if (!props.allowResize && props.allowDrag) {
xProps = assign(xProps, { cursor: "move" });
yProps = assign(yProps, { cursor: "auto" });
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should these both be "move" ?

} else if (!props.allowResize && !props.allowDrag) {
xProps = assign(xProps, { cursor: "auto" });
yProps = assign(yProps, { cursor: "auto" });
}
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