From 28d0b33b67dc832d5d428f8065a12bdbc5810d42 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Fri, 28 Oct 2016 17:21:58 -0700 Subject: [PATCH 1/2] use command | shift | ctrl | alt to enable perspective mode --- CHANGELOG.md | 4 ++++ README.md | 2 +- src/map-interactions.react.js | 14 ++++++++++---- src/map.react.js | 2 +- 4 files changed, 16 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 78f6543f..0f1e761e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Version 1.7.1 +* Use any one of the function keys {command, shift, ctrl, alt} to enable the + perspective mode. + # Version 1.7.0 * Provide a way to control per-layer interactivity - onClickFeatures and diff --git a/README.md b/README.md index 08ee65d7..9fe980a2 100644 --- a/README.md +++ b/README.md @@ -111,7 +111,7 @@ Perspective mode is exposed using the `pitch` and `bearing` props In addition, the `perspectiveEnabled` prop (default: `false`) will activate mouse handlers that allow the user to change `pitch` and -`bearing` using the mouse while holding down the "command" key. +`bearing` using the mouse while holding down any function key {command, shift, ctrl, alt}. If `perspectiveEnabled` is not set to `true` then the user will not be able to change the pitch and bearing, which means that the default props will show diff --git a/src/map-interactions.react.js b/src/map-interactions.react.js index 5e890827..42b0524e 100644 --- a/src/map-interactions.react.js +++ b/src/map-interactions.react.js @@ -96,6 +96,7 @@ export default class MapInteractions extends Component { super(props); this.state = { didDrag: false, + isFunctionKeyPressed: false, startPos: null, pos: null, mouseWheelPos: null @@ -114,6 +115,11 @@ export default class MapInteractions extends Component { }, new Point(0, 0)); } + _isFunctionKeyPressed(event) { + return Boolean(event.metaKey || event.altKey || + event.ctrlKey || event.shiftKey); + } + @autobind _onMouseDown(event) { const pos = this._getMousePos(event); @@ -121,7 +127,7 @@ export default class MapInteractions extends Component { didDrag: false, startPos: pos, pos, - metaKey: Boolean(event.metaKey) + isFunctionKeyPressed: this._isFunctionKeyPressed(event) }); this.props.onMouseDown({pos}); document.addEventListener('mousemove', this._onMouseDrag, false); @@ -135,7 +141,7 @@ export default class MapInteractions extends Component { didDrag: false, startPos: pos, pos, - metaKey: Boolean(event.metaKey) + isFunctionKeyPressed: this._isFunctionKeyPressed(event) }); this.props.onTouchStart({pos}); document.addEventListener('touchmove', this._onTouchDrag, false); @@ -146,7 +152,7 @@ export default class MapInteractions extends Component { _onMouseDrag(event) { const pos = this._getMousePos(event); this.setState({pos, didDrag: true}); - if (this.state.metaKey) { + if (this.state.isFunctionKeyPressed) { const {startPos} = this.state; this.props.onMouseRotate({pos, startPos}); } else { @@ -158,7 +164,7 @@ export default class MapInteractions extends Component { _onTouchDrag(event) { const pos = this._getTouchPos(event); this.setState({pos, didDrag: true}); - if (this.state.metaKey) { + if (this.state.isFunctionKeyPressed) { const {startPos} = this.state; this.props.onTouchRotate({pos, startPos}); } else { diff --git a/src/map.react.js b/src/map.react.js index 464234ab..866dda04 100644 --- a/src/map.react.js +++ b/src/map.react.js @@ -148,7 +148,7 @@ const PROP_TYPES = { preventStyleDiffing: PropTypes.bool, /** - * Enables perspective control event handling (Command-rotate) + * Enables perspective control event handling */ perspectiveEnabled: PropTypes.bool, From 4ac4e07348153b639105d561adc5b9ce794adcc7 Mon Sep 17 00:00:00 2001 From: Yang Wang Date: Fri, 28 Oct 2016 17:46:52 -0700 Subject: [PATCH 2/2] update change log --- CHANGELOG.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0f1e761e..d566165c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,10 @@ -# Version 1.7.1 +# Version 1.7.2 * Use any one of the function keys {command, shift, ctrl, alt} to enable the perspective mode. +# Version 1.7.1 +* Bump Mapbox version to 0.26 + # Version 1.7.0 * Provide a way to control per-layer interactivity - onClickFeatures and