From ab3b4e45551f236ac264e6c4f0e8039270662188 Mon Sep 17 00:00:00 2001 From: Paul Kaplan Date: Thu, 26 Oct 2017 17:42:15 -0400 Subject: [PATCH] Force a stroke width on pen and line mode --- src/containers/line-mode.jsx | 10 +++++++++- src/containers/pen-mode.jsx | 8 ++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/containers/line-mode.jsx b/src/containers/line-mode.jsx index 3716b619..a7e226c8 100644 --- a/src/containers/line-mode.jsx +++ b/src/containers/line-mode.jsx @@ -9,6 +9,7 @@ import {endPointHit, touching} from '../helper/snapping'; import {drawHitPoint, removeHitPoint} from '../helper/guides'; import {stylePath} from '../helper/style-path'; import {changeStrokeColor} from '../reducers/stroke-color'; +import {changeStrokeWidth} from '../reducers/stroke-width'; import {changeMode} from '../reducers/modes'; import {clearSelectedItems} from '../reducers/selected-items'; import {MIXED} from '../helper/style-path'; @@ -57,7 +58,11 @@ class LineMode extends React.Component { if (strokeColor === MIXED || strokeColor === null) { this.props.onChangeStrokeColor(LineMode.DEFAULT_COLOR); } - + // Force a minimum stroke width + console.log(this.props.colorState.strokeWidth) + if (!this.props.colorState.strokeWidth) { + this.props.onChangeStrokeWidth(1); + } this.tool = new paper.Tool(); this.path = null; @@ -248,6 +253,9 @@ const mapDispatchToProps = dispatch => ({ }, onChangeStrokeColor: strokeColor => { dispatch(changeStrokeColor(strokeColor)); + }, + onChangeStrokeWidth: strokeWidth => { + dispatch(changeStrokeWidth(strokeWidth)); } }); diff --git a/src/containers/pen-mode.jsx b/src/containers/pen-mode.jsx index 32ca4bc8..b1132538 100644 --- a/src/containers/pen-mode.jsx +++ b/src/containers/pen-mode.jsx @@ -5,6 +5,7 @@ import bindAll from 'lodash.bindall'; import Modes from '../modes/modes'; import {changeStrokeColor} from '../reducers/stroke-color'; +import {changeStrokeWidth} from '../reducers/stroke-width'; import {changeMode} from '../reducers/modes'; import {clearSelectedItems} from '../reducers/selected-items'; import {MIXED} from '../helper/style-path'; @@ -52,6 +53,10 @@ class PenMode extends React.Component { if (strokeColor === MIXED || strokeColor === null) { this.props.onChangeStrokeColor(PenMode.DEFAULT_COLOR) } + // Force a minimum stroke width + if (!this.props.colorState.strokeWidth) { + this.props.onChangeStrokeWidth(1); + } this.tool = new PenTool( this.props.clearSelectedItems, this.props.onUpdateSvg @@ -102,6 +107,9 @@ const mapDispatchToProps = dispatch => ({ }, onChangeStrokeColor: strokeColor => { dispatch(changeStrokeColor(strokeColor)); + }, + onChangeStrokeWidth: strokeWidth => { + dispatch(changeStrokeWidth(strokeWidth)); } });