Merge pull request #12416 from ahocevar/eventtype-generics

Use generics to limit event types in on(), once() and un()
This commit is contained in:
Andreas Hocevar
2021-06-21 09:36:25 +02:00
committed by GitHub
30 changed files with 49 additions and 7 deletions

View File

@@ -82,6 +82,7 @@ export class DragAndDropEvent extends Event {
* combinnation of formats read both text string and ArrayBuffer sources. Older browsers such
* as IE which do not support this will need a TextDecoder polyfill to be loaded before use.
*
* @extends Interaction<'addfeatures'>
* @api
*
* @fires DragAndDropEvent

View File

@@ -103,6 +103,7 @@ export class DragBoxEvent extends Event {
* {@link module:ol/interaction/DragRotateAndZoom}).
*
* @fires DragBoxEvent
* @extends PointerInteraction<'boxcancel'|'boxdrag'|'boxend'>
* @api
*/
class DragBox extends PointerInteraction {

View File

@@ -177,6 +177,7 @@ export class DrawEvent extends Event {
* Interaction for drawing feature geometries.
*
* @fires DrawEvent
* @extends PointerInteraction<'drawabort'|'drawend'|'drawstart'>
* @api
*/
class Draw extends PointerInteraction {

View File

@@ -81,6 +81,7 @@ export class ExtentEvent extends Event {
* This interaction is only supported for mouse devices.
*
* @fires ExtentEvent
* @extends PointerInteraction<'extentchanged'>
* @api
*/
class Extent extends PointerInteraction {

View File

@@ -27,6 +27,9 @@ import {easeOut, linear} from '../easing.js';
* by a keyboard event not a button element event.
* Although interactions do not have a DOM element, some of them do render
* vectors and so are visible on the screen.
*
* @template {string} EventTypes
* @extends BaseObject<EventTypes|'change:active'>
* @api
*/
class Interaction extends BaseObject {

View File

@@ -183,6 +183,7 @@ export class ModifyEvent extends Event {
* key is pressed. To configure the interaction with a different condition
* for deletion, use the `deleteCondition` option.
* @fires ModifyEvent
* @extends PointerInteraction<'modifyend'|'modifystart'>
* @api
*/
class Modify extends PointerInteraction {

View File

@@ -41,6 +41,9 @@ import {getValues} from '../obj.js';
* started. During a drag sequence the `handleDragEvent` user function is
* called on `move` events. The drag sequence ends when the `handleUpEvent`
* user function is called and returns `false`.
*
* @template {string} EventTypes
* @extends Interaction<EventTypes>
* @api
*/
class PointerInteraction extends Interaction {

View File

@@ -147,6 +147,7 @@ const originalFeatureStyles = {};
* Selected features are added to an internal unmanaged layer.
*
* @fires SelectEvent
* @extends Interaction<'select'>
* @api
*/
class Select extends Interaction {

View File

@@ -115,6 +115,7 @@ export class TranslateEvent extends Event {
* Interaction for translating (moving) features.
*
* @fires TranslateEvent
* @extends PointerInteraction<'translateend'|'translatestart'|'translating'>
* @api
*/
class Translate extends PointerInteraction {