forked from mapbox/mapbox-gl-draw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Check for map canvas using classList.contains() (mapbox#1165) (h/t @n…
…eodescis) Co-authored-by: Nick Steinbaugh <nsteinbaugh@icr-team.com>
- Loading branch information
Showing
2 changed files
with
13 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,36 @@ | ||
import createSyntheticEvent from 'synthetic-dom-events'; | ||
|
||
const classList = ['mapboxgl-canvas']; | ||
classList.contains = function(cls) { | ||
return classList.indexOf(cls) >= 0; | ||
}; | ||
|
||
export const enterEvent = createSyntheticEvent('keyup', { | ||
srcElement: { classList: ['mapboxgl-canvas']}, | ||
srcElement: { classList }, | ||
keyCode: 13 | ||
}); | ||
|
||
export const startPointEvent = createSyntheticEvent('keydown', { | ||
srcElement: { classList: ['mapboxgl-canvas']}, | ||
srcElement: { classList }, | ||
keyCode: 49 | ||
}); | ||
|
||
export const startLineStringEvent = createSyntheticEvent('keydown', { | ||
srcElement: { classList: ['mapboxgl-canvas']}, | ||
srcElement: { classList }, | ||
keyCode: 50 | ||
}); | ||
|
||
export const startPolygonEvent = createSyntheticEvent('keydown', { | ||
srcElement: { classList: ['mapboxgl-canvas']}, | ||
srcElement: { classList }, | ||
keyCode: 51 | ||
}); | ||
|
||
export const escapeEvent = createSyntheticEvent('keyup', { | ||
srcElement: { classList: ['mapboxgl-canvas']}, | ||
srcElement: { classList }, | ||
keyCode: 27 | ||
}); | ||
|
||
export const backspaceEvent = createSyntheticEvent('keydown', { | ||
srcElement: { classList: ['mapboxgl-canvas']}, | ||
srcElement: { classList }, | ||
keyCode: 8 | ||
}); |