diff options
author | Bob Zeleznik <zzzman@gmail.com> | 2019-05-11 21:40:18 -0400 |
---|---|---|
committer | Bob Zeleznik <zzzman@gmail.com> | 2019-05-11 21:40:18 -0400 |
commit | 8eec22e546b6c6a4b8891deef3c666774cb105fe (patch) | |
tree | b9cc5067d1cd2831cc4c58bd44d27b589838fae0 /src/client/views/InkingCanvas.tsx | |
parent | f105afd4c239940ebc41ae370b4203248cdb7b26 (diff) |
fixed some panning issues with ink and zoom
Diffstat (limited to 'src/client/views/InkingCanvas.tsx')
-rw-r--r-- | src/client/views/InkingCanvas.tsx | 8 |
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(() => { |