diff --git a/src/ol/interaction/translate.js b/src/ol/interaction/translate.js index 9d57e4d37b..dd07cc557b 100644 --- a/src/ol/interaction/translate.js +++ b/src/ol/interaction/translate.js @@ -171,7 +171,8 @@ ol.interaction.Translate.handleMoveEvent_ = function(event) { // Change the cursor to grab/grabbing if hovering any of the features managed // by the interaction if (this.featuresAtPixel_(event.pixel, event.map)) { - this.previousCursor_ = elem.style.cursor; + this.previousCursor_ = this.previousCursor_ !== undefined ? + this.previousCursor_ : elem.style.cursor; // WebKit browsers don't support the grab icons without a prefix elem.style.cursor = this.lastCoordinate_ ? '-webkit-grabbing' : '-webkit-grab'; @@ -179,9 +180,8 @@ ol.interaction.Translate.handleMoveEvent_ = function(event) { // Thankfully, attempting to set the standard ones will silently fail, // keeping the prefixed icons elem.style.cursor = this.lastCoordinate_ ? 'grabbing' : 'grab'; - } else { - elem.style.cursor = this.previousCursor_ !== undefined ? - this.previousCursor_ : ''; + } else if (this.previousCursor_ !== undefined) { + elem.style.cursor = this.previousCursor_; this.previousCursor_ = undefined; } }; diff --git a/test/spec/ol/interaction/translate.test.js b/test/spec/ol/interaction/translate.test.js index e167f3afd5..5cec115461 100644 --- a/test/spec/ol/interaction/translate.test.js +++ b/test/spec/ol/interaction/translate.test.js @@ -56,13 +56,13 @@ describe('ol.interaction.Translate', function() { }); /** - * Simulates a browser event on the map viewport. The client x/y location - * will be adjusted as if the map were centered at 0,0. - * @param {string} type Event type. - * @param {number} x Horizontal offset from map center. - * @param {number} y Vertical offset from map center. - * @param {boolean=} opt_shiftKey Shift key is pressed. - */ + * Simulates a browser event on the map viewport. The client x/y location + * will be adjusted as if the map were centered at 0,0. + * @param {string} type Event type. + * @param {number} x Horizontal offset from map center. + * @param {number} y Vertical offset from map center. + * @param {boolean=} opt_shiftKey Shift key is pressed. + */ function simulateEvent(type, x, y, opt_shiftKey) { var viewport = map.getViewport(); // calculated in case body has top < 0 (test runner with small window) @@ -99,12 +99,12 @@ describe('ol.interaction.Translate', function() { } /** - * Validates the event array to verify proper event sequence. Checks - * that first and last event are correct TranslateEvents and that feature - * modifications event are in between. - * @param {Array