aboutsummaryrefslogtreecommitdiff
path: root/src/client/views/InkingCanvas.tsx
diff options
context:
space:
mode:
authorBob Zeleznik <zzzman@gmail.com>2019-05-11 21:40:18 -0400
committerBob Zeleznik <zzzman@gmail.com>2019-05-11 21:40:18 -0400
commit8eec22e546b6c6a4b8891deef3c666774cb105fe (patch)
treeb9cc5067d1cd2831cc4c58bd44d27b589838fae0 /src/client/views/InkingCanvas.tsx
parentf105afd4c239940ebc41ae370b4203248cdb7b26 (diff)
fixed some panning issues with ink and zoom
Diffstat (limited to 'src/client/views/InkingCanvas.tsx')
-rw-r--r--src/client/views/InkingCanvas.tsx8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/client/views/InkingCanvas.tsx b/src/client/views/InkingCanvas.tsx
index 1c0d13545..afe3e3ecb 100644
--- a/src/client/views/InkingCanvas.tsx
+++ b/src/client/views/InkingCanvas.tsx
@@ -30,6 +30,14 @@ export class InkingCanvas extends React.Component<InkCanvasProps> {
selRect.top < val.y && selRect.top + selRect.height > val.y)
, false);
}
+ public static StrokeRect(stroke: StrokeData): { left: number, top: number, right: number, bottom: number } {
+ return stroke.pathData.reduce((bounds: { left: number, top: number, right: number, bottom: number }, val) =>
+ ({
+ left: Math.min(bounds.left, val.x), top: Math.min(bounds.top, val.y),
+ right: Math.max(bounds.right, val.x), bottom: Math.max(bounds.bottom, val.y)
+ })
+ , { left: Number.MAX_VALUE, top: Number.MAX_VALUE, right: -Number.MAX_VALUE, bottom: -Number.MAX_VALUE });
+ }
componentDidMount() {
PromiseValue(Cast(this.props.Document.ink, InkField)).then(ink => runInAction(() => {