Fixes arrow rendering when style changes
This commit is contained in:
parent
87551353fe
commit
d22b31000e
1 changed files with 2 additions and 11 deletions
|
@ -32,8 +32,6 @@ import getStroke from 'perfect-freehand'
|
||||||
import React from 'react'
|
import React from 'react'
|
||||||
import { registerShapeUtils } from './register'
|
import { registerShapeUtils } from './register'
|
||||||
|
|
||||||
const pathCache = new WeakMap<ArrowShape['handles'], string>([])
|
|
||||||
|
|
||||||
// A cache for semi-expensive circles calculated from three points
|
// A cache for semi-expensive circles calculated from three points
|
||||||
function getCtp(shape: ArrowShape) {
|
function getCtp(shape: ArrowShape) {
|
||||||
const { start, end, bend } = shape.handles
|
const { start, end, bend } = shape.handles
|
||||||
|
@ -129,9 +127,7 @@ const arrow = registerShapeUtils<ArrowShape>({
|
||||||
const sw = strokeWidth * (isDraw ? 0.618 : 1.618)
|
const sw = strokeWidth * (isDraw ? 0.618 : 1.618)
|
||||||
|
|
||||||
const path = isDraw
|
const path = isDraw
|
||||||
? getFromCache(pathCache, shape.handles, (cache) =>
|
? renderFreehandArrowShaft(shape)
|
||||||
cache.set(shape.handles, renderFreehandArrowShaft(shape))
|
|
||||||
)
|
|
||||||
: 'M' + vec.round(start.point) + 'L' + vec.round(end.point)
|
: 'M' + vec.round(start.point) + 'L' + vec.round(end.point)
|
||||||
|
|
||||||
const { strokeDasharray, strokeDashoffset } = getPerfectDashProps(
|
const { strokeDasharray, strokeDashoffset } = getPerfectDashProps(
|
||||||
|
@ -173,12 +169,7 @@ const arrow = registerShapeUtils<ArrowShape>({
|
||||||
const sw = strokeWidth * (isDraw ? 0.618 : 1.618)
|
const sw = strokeWidth * (isDraw ? 0.618 : 1.618)
|
||||||
|
|
||||||
const path = isDraw
|
const path = isDraw
|
||||||
? getFromCache(pathCache, shape.handles, (cache) =>
|
? renderCurvedFreehandArrowShaft(shape, circle)
|
||||||
cache.set(
|
|
||||||
shape.handles,
|
|
||||||
renderCurvedFreehandArrowShaft(shape, circle)
|
|
||||||
)
|
|
||||||
)
|
|
||||||
: getArrowArcPath(start, end, circle, bend)
|
: getArrowArcPath(start, end, circle, bend)
|
||||||
|
|
||||||
const arcLength = getArcLength(
|
const arcLength = getArcLength(
|
||||||
|
|
Loading…
Reference in a new issue