aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/InkingStroke.tsx
diff options
context:
space:
mode:
authorbobzel <zzzman@gmail.com>2021-09-29 22:51:21 -0400
committerbobzel <zzzman@gmail.com>2021-09-29 22:51:21 -0400
commit1d2f03125cbfd1c7a03f0000454de4d70e73d690 (patch)
tree22ff01b179e1430b7a59b6a5356eb54966486bb1 /src/client/views/InkingStroke.tsx
parentb9adc2fec10d4509cd96558bb832f7c02bc70b25 (diff)
made IsClosed a static function. fixed warnings and errors.
Diffstat (limited to 'src/client/views/InkingStroke.tsx')
-rw-r--r--src/client/views/InkingStroke.tsx6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/client/views/InkingStroke.tsx b/src/client/views/InkingStroke.tsx
index 552318e23..42a09fa52 100644
--- a/src/client/views/InkingStroke.tsx
+++ b/src/client/views/InkingStroke.tsx
@@ -29,6 +29,9 @@ const InkDocument = makeInterface(documentSchema);
export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocument>(InkDocument) {
public static LayoutString(fieldStr: string) { return FieldView.LayoutString(InkingStroke, fieldStr); }
static readonly MaskDim = 50000;
+ public static IsClosed(inkData: InkData) {
+ return inkData && inkData.lastElement().X === inkData[0].X && inkData.lastElement().Y === inkData[0].Y;
+ }
@observable private _properties?: InkStrokeProperties;
_handledClick = false; // flag denoting whether ink stroke has handled a psuedo-click onPointerUp so that the real onClick event can be stopPropagated
_selDisposer: IReactionDisposer | undefined;
@@ -144,7 +147,6 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume
const inkDoc = this.props.Document;
const screenSpaceCenterlineStrokeWidth = 3; // the width of the blue line widget that shows the centerline of the ink stroke
const { inkData, inkScaleX, inkScaleY, inkStrokeWidth, inkTop, inkLeft } = this.inkScaledData();
- const closed = inkData.lastElement().X === inkData[0].X && inkData.lastElement().Y === inkData[0].Y;
const screenInkWidth = this.props.ScreenToLocalTransform().inverse().transformDirection(inkStrokeWidth, inkStrokeWidth);
const screenPts = inkData.map(point => this.props.ScreenToLocalTransform().inverse().transformPoint(
@@ -184,7 +186,7 @@ export class InkingStroke extends ViewBoxBaseComponent<FieldViewProps, InkDocume
const startMarker = StrCast(this.layoutDoc.strokeStartMarker);
const endMarker = StrCast(this.layoutDoc.strokeEndMarker);
- const closed = inkData.lastElement().X === inkData[0].X && inkData.lastElement().Y === inkData[0].Y;
+ const closed = InkingStroke.IsClosed(inkData);
const fillColor = StrCast(this.layoutDoc.fillColor, "transparent");
const strokeColor = !closed && fillColor && fillColor !== "transparent" ? fillColor : StrCast(this.layoutDoc.color);