diff --git a/packages/react-native-draw/README.md b/packages/react-native-draw/README.md index eb25c6d..088185c 100644 --- a/packages/react-native-draw/README.md +++ b/packages/react-native-draw/README.md @@ -206,7 +206,7 @@ https://user-images.githubusercontent.com/22248828/152837922-757d3a13-1d35-409a- ### Canvas | name | description | type | default | -| ----------------------- | ----------------------------------------------------------------------------------------- | ---------------------------------------------- | ----------------------------- | +|-------------------------|-------------------------------------------------------------------------------------------| ---------------------------------------------- |-------------------------------| | `color` | Color of the brush strokes | `string` | - (required) | | `thickness` | Thickness of the brush strokes | `number` | - (required) | | `opacity` | Opacity of the brush strokes | `number` | - (required) | @@ -220,6 +220,7 @@ https://user-images.githubusercontent.com/22248828/152837922-757d3a13-1d35-409a- | `tool` | Initial tool of the canvas | `brush` or `eraser` | `brush` | | `combineWithLatestPath` | Combine current path with the last path if it's the same color, thickness, and opacity | `boolean` | `false` | | `enabled` | Allows for the canvas to be drawn on, put to false if you want to disable/lock the canvas | `boolean` | `true` | +| `shouldCancelWhenOutside`| When true, drawing will cancel if the touch moves outside of the view | `boolean` | `false` | ### SimplifyOptions diff --git a/packages/react-native-draw/src/Canvas.tsx b/packages/react-native-draw/src/Canvas.tsx index 2786e14..71ab41a 100644 --- a/packages/react-native-draw/src/Canvas.tsx +++ b/packages/react-native-draw/src/Canvas.tsx @@ -110,6 +110,12 @@ export interface CanvasProps { * @default true */ enabled?: boolean; + + /** + * when true, drawing will cancel the gesture if the touch moves outside of the view + * @default false + */ + shouldCancelWhenOutside?: boolean; } export interface SimplifyOptions { @@ -219,6 +225,7 @@ const Canvas = forwardRef( tool = DEFAULT_TOOL, combineWithLatestPath = false, enabled = true, + shouldCancelWhenOutside = false, }, ref ) => { @@ -435,7 +442,7 @@ const Canvas = forwardRef( top: 0, left: 0, }) - .shouldCancelWhenOutside(true) + .shouldCancelWhenOutside(shouldCancelWhenOutside) .enabled(enabled); return (