Adds option to retain MousePosition when pointer leaves viewport

This commit is contained in:
Pete Schmitt authored and ahocevar committed 2018-04-23 08:47:15 +02:00
1 parent 33ca22a4dc
commit 2e3e7d282a
2 files changed
+100 -4

No files matched your search

+8 -4
View File
@@ -72,6 +72,8 @@ const MousePosition = function(opt_options) {
this.setProjection(options.projection);
}
this.clearOnMouseOut_ = options.clearOnMouseOut !== undefined ? options.clearOnMouseOut : true;
/**
* @private
* @type {string}
@@ -190,11 +192,13 @@ MousePosition.prototype.setMap = function(map) {
if (map) {
const viewport = map.getViewport();
this.listenerKeys.push(
listen(viewport, EventType.MOUSEMOVE,
this.handleMouseMove, this),
listen(viewport, EventType.MOUSEOUT,
this.handleMouseOut, this)
listen(viewport, EventType.MOUSEMOVE, this.handleMouseMove, this)
);
if (this.clearOnMouseOut_) {
this.listenerKeys.push(
listen(viewport, EventType.MOUSEOUT, this.handleMouseOut, this)
);
}
}
};