-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix SnapEvent types and add unit tests for SnapEvent
- Loading branch information
1 parent
8827a91
commit 1832a0a
Showing
4 changed files
with
154 additions
and
35 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,10 +1,51 @@ | ||
import BaseEvent from './Event.js'; | ||
/** | ||
* @module ol/events/SnapEvent | ||
*/ | ||
import Event from './Event.js'; | ||
|
||
export class SnapEvent extends BaseEvent { | ||
constructor(options) { | ||
super('snap'); | ||
/** | ||
* @enum {string} | ||
*/ | ||
export const SnapEventType = { | ||
/** | ||
* Triggered upon snapping to vertex or edge | ||
* @event SnapEvent#snap | ||
* @api | ||
*/ | ||
SNAP: 'snap', | ||
}; | ||
|
||
/** | ||
* @classdesc | ||
* Events emitted by {@link module:ol/interaction/Snap~Snap} instances are instances of this | ||
*/ | ||
export class SnapEvent extends Event { | ||
/** | ||
* @param {SnapEventType} type Type. | ||
* @param {Object} options Options. | ||
* @param {import("../coordinate.js").Coordinate} options.vertex The snapped vertex. | ||
* @param {import("../coordinate.js").Coordinate} options.vertexPixel The pixel of the snapped vertex. | ||
* @param {import("../Feature.js").default} options.feature The feature being snapped. | ||
*/ | ||
constructor(type, options) { | ||
super(type); | ||
/** | ||
* The Map coordinate of the snapped point. | ||
* @type {import("../coordinate.js").Coordinate} | ||
* @api | ||
*/ | ||
this.vertex = options.vertex; | ||
/** | ||
* The Map pixel of the snapped point. | ||
* @type {Array<number>&Array<number>} | ||
* @api | ||
*/ | ||
this.vertexPixel = options.vertexPixel; | ||
/** | ||
* The feature closest to the snapped point. | ||
* @type {import("../Feature.js").default<import("../geom/Geometry.js").default>} | ||
* @api | ||
*/ | ||
this.feature = options.feature; | ||
} | ||
} |
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
Oops, something went wrong.