diff options
| author | Andrej Mihajlov <and@codeispoetry.ru> | 2017-02-17 17:19:53 +0000 |
|---|---|---|
| committer | Andrej Mihajlov <and@codeispoetry.ru> | 2017-02-17 17:19:53 +0000 |
| commit | 1e01196376bb47cb095419acb6f440f528c329c8 (patch) | |
| tree | d327bf0ebf3892c173d7d0b93ad12cec670ca9ed | |
| parent | 40c85aa2d47d587792bf7cb5024565b2419b2e36 (diff) | |
| download | mullvadvpn-1e01196376bb47cb095419acb6f440f528c329c8.tar.xz mullvadvpn-1e01196376bb47cb095419acb6f440f528c329c8.zip | |
Clean up code
| -rw-r--r-- | app/components/Settings.js | 1 | ||||
| -rw-r--r-- | app/components/Switch.js | 26 |
2 files changed, 14 insertions, 13 deletions
diff --git a/app/components/Settings.js b/app/components/Settings.js index 89b70ec69f..0085cfc820 100644 --- a/app/components/Settings.js +++ b/app/components/Settings.js @@ -17,7 +17,6 @@ export default class Settings extends Component { } handleAutoSecure(isOn) { - console.log('autoSecure: ' + isOn); this.props.updateSettings({ autoSecure: isOn }); } diff --git a/app/components/Switch.js b/app/components/Switch.js index e2a4b7389d..dd3af133ad 100644 --- a/app/components/Switch.js +++ b/app/components/Switch.js @@ -16,8 +16,7 @@ export default class Switch extends Component { isTracking: false, ignoreChange: false, initialPos: null, - startTime: null, - target: null + startTime: null }; } @@ -33,34 +32,37 @@ export default class Switch extends Component { handleMouseMove(e) { if(!this.state.isTracking) { return; } - const { x: startX } = this.state.initialPos; + const { x: x0 } = this.state.initialPos; const { pageX: x, pageY: y } = e; - - const dx = Math.abs(startX - x); + const dx = Math.abs(x0 - x); if(dx < MOVE_THRESHOLD) { return; } const isOn = !!this.props.isOn; let nextOn = isOn; - if(x < startX && isOn) { + if(x < x0 && isOn) { nextOn = false; - } else if(x > startX && !isOn) { + } else if(x > x0 && !isOn) { nextOn = true; } if(isOn !== nextOn) { - this.setState({ initialPos: { x, y } }); + this.setState({ + initialPos: { x, y }, + ignoreChange: true + }); this.refs.input.checked = nextOn; this.notify(nextOn); - this.setState({ ignoreChange: true }); } } handleMouseUp() { if(this.state.isTracking) { - this.setState({ isTracking: false, initialPos: null }); - console.log('mouseup'); + this.setState({ + isTracking: false, + initialPos: null + }); } } @@ -68,8 +70,8 @@ export default class Switch extends Component { const dt = e.timeStamp - this.state.startTime; if(this.state.ignoreChange) { - e.preventDefault(); this.setState({ ignoreChange: false }); + e.preventDefault(); } else if(dt > CLICK_TIMEOUT) { e.preventDefault(); } else { |
