Fix horizontal verticakl logic

This commit is contained in:
2018-07-02 11:06:43 +05:30
parent 73e87d472f
commit 7cef39b11c
+14 -8
View File
@@ -78,9 +78,14 @@ class GridArea extends PureComponent<GridAreaProps, {}> {
const style = {...GridArea.defaultStyle, ...this.props.style}; const style = {...GridArea.defaultStyle, ...this.props.style};
const isVertical = (this.props.direction === Direction.VERTICAL); const isVertical = (this.props.direction === Direction.VERTICAL);
const tickXAttr = isVertical ? 'y' : 'x';
const tickYAttr = isVertical ? 'x' : 'y'; const primaryAxisName = isVertical ? 'y' : 'x';
const length = isVertical ? height : width; const crossAxisName = isVertical ? 'x' : 'y';
const primaryLengthAttr = isVertical ? 'height' : 'width';
const crossLengthAttr = isVertical ? 'width' : 'height';
const primaryLength = isVertical ? height : width;
const crossLength = isVertical ? width : height;
const scale = getAttributeScale({ const scale = getAttributeScale({
...this.props, ...this.props,
@@ -88,7 +93,7 @@ class GridArea extends PureComponent<GridAreaProps, {}> {
height, height,
top, top,
left left
}, 'y'); }, primaryAxisName);
const values = this.props.highlightRegion; const values = this.props.highlightRegion;
return ( return (
@@ -105,11 +110,12 @@ class GridArea extends PureComponent<GridAreaProps, {}> {
const maxPos = Math.max(...pos); const maxPos = Math.max(...pos);
const rectProps = { const rectProps = {
x: 0, [crossAxisName]: 0,
width: width, [crossLengthAttr]: crossLength,
y: minPos, [primaryAxisName]: minPos,
height: maxPos - minPos, [primaryLengthAttr]: maxPos - minPos,
}; };
debugger;
return ( return (
<rect <rect
{...rectProps} {...rectProps}