Skip to content

Commit

Permalink
4.9.6 fix(mapjs): Fix zoom keyboard shortcuts:
Browse files Browse the repository at this point in the history
    - mapjs/src/browser/dom-map-widget.js`: Fix zoom keyboard shortcuts:
      - Now using keyCode, instead of keyIdentifier which didn't work.
      However, keyCode is deprecated: ISSUE s6mike/mapjs#3
      - Add 2 missing key codes.
  • Loading branch information
s6mike committed Oct 10, 2022
1 parent dead95e commit f4a70f4
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 6 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
- Add note about linking/using templates (html and latex) with pandoc.
- Add references to argmap specs?

## argmap 4.9.6

- mapjs/src/browser/dom-map-widget.js`: Fix zoom in/out keyboard shortcuts:
- Now using keyCode, instead of keyIdentifier which didn't work. However, keyCode is deprecated: ISSUE s6mike/mapjs#3
- Add 2 missing key codes.

## argmap 4.9.5

- `test/test_scripts/headless_chrome_repl_mapjs_is_rendered.exp`: Updated chrome crash dumps dir to be `/tmp`, rather than inside project directory.
Expand Down
12 changes: 9 additions & 3 deletions mapjs/src/browser/dom-map-widget.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,17 +186,23 @@ $.fn.domMapWidget = function (activityLog, mapModel, touchEnabled, dragContainer
}

});
// ISSUE: Listening at document level is unintuitive, should add this at container level like the rest.
// https://github.com/s6mike/mapjs/issues/4
$(document).on('keydown', function (e) {
const functions = {
'U+003D': 'scaleUp',
'U+002D': 'scaleDown',
61: 'scaleUp',
173: 'scaleDown'
173: 'scaleDown',
187: 'scaleUp',
189: 'scaleDown',
};
let mappedFunction;
if (e && !e.altKey && (e.ctrlKey || e.metaKey)) {
if (e.originalEvent && e.originalEvent.keyIdentifier) { /* webkit */
mappedFunction = functions[e.originalEvent.keyIdentifier];
// ISSUE: keyCode event works, but is deprecated
// https://github.com/s6mike/mapjs/issues/3
if (e.originalEvent && e.originalEvent.keyCode) { /* webkit */
mappedFunction = functions[e.originalEvent.keyCode];
} else if (e.key === 'MozPrintableKey') {
mappedFunction = functions[e.which];
}
Expand Down

0 comments on commit f4a70f4

Please sign in to comment.