Skip to content

Commit

Permalink
Merge pull request #2800 from ZakarFin/cursor-style
Browse files Browse the repository at this point in the history
Add a ~setterId for map cursor to detect unintentional reseting
  • Loading branch information
ZakarFin authored Mar 3, 2025
2 parents 2e6696b + aca29b0 commit deceabc
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
18 changes: 14 additions & 4 deletions bundles/mapping/mapmodule/AbstractMapModule.js
Original file line number Diff line number Diff line change
Expand Up @@ -1354,10 +1354,20 @@ Oskari.clazz.define(
getCursorStyle: function () {
return this._cursorStyle;
},
setCursorStyle: function (cursorStyle) {
var element = this.getMapEl();
jQuery(element).css('cursor', cursorStyle);

setCursorStyle: function (cursorStyle = '', setBy) {
const element = this.getMapDOMEl();
if (setBy !== this._cursorStyleLastSetBy && !cursorStyle) {
// if reseting and we are not the last that set the style, do nothing
// Otherwise there's a race condition with findbycoordinates and markerplugin
// both set style on start and reset it at stop but the start order matters which one wins
return;
}
if (element?.style) {
element.style.cursor = cursorStyle;
}
this._cursorStyle = cursorStyle;
this._cursorStyleLastSetBy = setBy;
return this._cursorStyle;
},

Expand Down Expand Up @@ -2431,7 +2441,7 @@ Oskari.clazz.define(
});

rpcService.addFunction('setCursorStyle', function (cursorStyle) {
return me.setCursorStyle(cursorStyle);
return me.setCursorStyle(cursorStyle, 'RPC');
});

rpcService.addFunction('getVectorFeatures', function (geojsonFilter, opts) {
Expand Down
4 changes: 2 additions & 2 deletions bundles/mapping/mapmodule/plugin/markers/MarkersPlugin.ol.js
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ Oskari.clazz.define('Oskari.mapframework.mapmodule.MarkersPlugin',
this.markerPopupControls = showMarkerPopup(() => this.removeMarkers(), () => this.closeMarkerPopup());
}

this.getMapModule().setCursorStyle('crosshair');
this.getMapModule().setCursorStyle('crosshair', this.getName());
},
/**
* Stops the marker location selector
Expand All @@ -267,7 +267,7 @@ Oskari.clazz.define('Oskari.mapframework.mapmodule.MarkersPlugin',
if (this.popupControls) {
this.popupCleanup();
}
this.getMapModule().setCursorStyle('');
this.getMapModule().setCursorStyle('', this.getName());
if (!selectDefault) {
return;
}
Expand Down

0 comments on commit deceabc

Please sign in to comment.