UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

64 lines (62 loc) 3.03 kB
import type { EventNames } from "../core/Evented.js"; import type { ResourceHandle } from "../core/Handles.js"; import type { SceneViewEventTypes } from "./types.js"; /** @since 5.0 */ export type Viewport2DMixinEvents = SceneViewEventTypes; /** * Mixin that adds event handling capabilities to [View2D](https://developers.arcgis.com/javascript/latest/references/core/views/View2D/) and [VideoView](https://developers.arcgis.com/javascript/latest/references/core/views/VideoView/). * * @since 5.0 */ export abstract class Viewport2DMixin { constructor(...args: any[]); /** @since 5.0 */ "@eventTypes": Viewport2DMixinEvents; /** * Registers an event handler on the instance. Call this method to hook an * event with a listener. See the [Events summary table](https://developers.arcgis.com/javascript/latest/references/core/views/Viewport2DMixin/#events-summary) * for a list of listened events. * * @param type - The name of the event or events to listen for. * @param listener - The function to call when the event is fired, if modifiers were specified. * @returns Returns an event handler with a `remove()` method that * can be called to stop listening for the event. * * Property | Type | Description * ------------|--------|---------------- * remove | Function | When called, removes the listener from the event. * @since 5.0 * @example * view.on("click", function(event){ * // event is the event handle returned after the event fires. * console.log(event.mapPoint); * }); * * // Fires `pointer-move` event when user clicks on "Shift" * // key and moves the pointer on the view. * view.on("pointer-move", ["Shift"], function(event){ * let point = view2d.toMap({x: event.x, y: event.y}); * bufferPoint(point); * }); */ on<Type extends EventNames<this>>(type: Type, listener: (event: this["@eventTypes"][Type]) => void): ResourceHandle; /** * @param type - The name of the event or events to listen for. * @param modifiers - Additional modifier keys to filter events. * Please see [Key Values](https://developer.mozilla.org/en-US/docs/Web/API/KeyboardEvent/key/Key_Values) * for possible values. All the standard key values are supported. * Alternatively, if no modifiers are required, the function will call when the event fires. * * The following events don't support modifier keys: `blur`, `focus`, `layerview-create`, `layerview-destroy`, * `resize`. * @param listener - The function to call when the event is fired, if modifiers were specified. * @returns Returns an event handler with a `remove()` method that * can be called to stop listening for the event. * * Property | Type | Description * ------------|--------|---------------- * remove | Function | When called, removes the listener from the event. * @since 5.0 */ on<Type extends EventNames<this>>(type: Type, modifiers: string[], listener: (event: this["@eventTypes"][Type]) => void): ResourceHandle; }