kdeloach / react-lineto

Draw a line between two elements in React
MIT License
234 stars 63 forks source link

Change the break point in SteppedLine #49

Open iagows opened 3 years ago

iagows commented 3 years ago

There is a const x2 = (x0 + x1) / 2; and a const y2 = (y0 + y1) / 2;. Maybe this / 2 could be an parameter (defaults to 0.5) so the user could change this to avoid overlaping with some other elements in screen.

Something like this:

const defaultPercentBreakPoint = 0.5;

...

 renderVertical() {
...
const y2 = (y0 + y1) * (percentBreak ?? this.defaultPercentBreakPoint);
...
}

renderHorizontal(){
...
const x2 = (x0 + x1) * (percentBreak ?? this.defaultPercentBreakPoint);
...
}

SteppedLine.propTypes = Object.assign({}, {
    x0: PropTypes.number.isRequired,
    y0: PropTypes.number.isRequired,
    x1: PropTypes.number.isRequired,
    y1: PropTypes.number.isRequired,
    orientation: PropTypes.oneOf(['h', 'v']),
   percentBreak: PropTypes.number,
}, optionalStyleProps);