Add Arrowheads to Arrows (#2452)

Co-authored-by: dwelle <luzar.david@gmail.com>
Co-authored-by: Lipis <lipiridis@gmail.com>
This commit is contained in:
Steve Ruiz 2020-12-08 15:02:55 +00:00 committed by GitHub
parent bd8e860d7f
commit c291edfc44
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
25 changed files with 711 additions and 101 deletions

View file

@ -2576,6 +2576,14 @@ class App extends React.Component<ExcalidrawProps, AppState> {
pointerDownState.origin.y,
elementType === "draw" ? null : this.state.gridSize,
);
// If arrow is pre-arrowheads, it will have undefined for both start and end arrowheads.
// If so, we want it to be null/"arrow". If the linear item is not an arrow, we want it
// to be null/null. Otherwise, we want it to use the currentItemArrowheads values.
const { start, end } = this.state.currentItemArrowheads;
const [startArrowhead, endArrowhead] =
elementType === "arrow" ? [start, end] : [null, null];
const element = newLinearElement({
type: elementType,
x: gridX,
@ -2588,6 +2596,8 @@ class App extends React.Component<ExcalidrawProps, AppState> {
roughness: this.state.currentItemRoughness,
opacity: this.state.currentItemOpacity,
strokeSharpness: this.state.currentItemLinearStrokeSharpness,
startArrowhead,
endArrowhead,
});
this.setState((prevState) => ({
selectedElementIds: {