@@ -9,6 +9,7 @@ const turfBboxPoly = require('@turf/bbox-polygon');
99const turfTruncate = require ( '@turf/truncate' ) ;
1010const turfDestination = require ( '@turf/destination' ) ;
1111const turfDistance = require ( '@turf/distance' ) ;
12+ const turfBearing = require ( '@turf/bearing' ) ;
1213const turfHelpers = require ( '@turf/helpers' ) ;
1314
1415if ( window && typeof window . MapboxCircle === 'function' ) {
@@ -448,12 +449,36 @@ class MapboxCircle {
448449 }
449450 }
450451
452+ /**
453+ * Return vertical or horizontal resize arrow depending on if mouse is at left-right or top-bottom edit handles.
454+ * @param {MapMouseEvent } event
455+ * @return {string } 'ew-resize' or 'ns-resize'
456+ * @private
457+ */
458+ _getRadiusHandleCursorStyle ( event ) {
459+ const bearing = turfBearing ( event . lngLat . toArray ( ) , this . _currentCenterLngLat , true ) ;
460+
461+ if ( bearing > 270 + 45 || bearing <= 45 ) { // South.
462+ return 'ns-resize' ;
463+ }
464+ if ( bearing > 45 && bearing <= 90 + 45 ) { // West.
465+ return 'ew-resize' ;
466+ }
467+ if ( bearing > 90 + 45 && bearing <= 180 + 45 ) { // North.
468+ return 'ns-resize' ;
469+ }
470+ if ( bearing > 270 - 45 && bearing <= 270 + 45 ) { // East.
471+ return 'ew-resize' ;
472+ }
473+ }
474+
451475 /**
452476 * Highlight radius handles and disable panning.
477+ * @param {MapMouseEvent } event
453478 * @private
454479 */
455- _onRadiusHandlesMouseEnter ( ) {
456- this . _highlightHandles ( this . _circleRadiusHandlesId , 'ew-resize' ) ;
480+ _onRadiusHandlesMouseEnter ( event ) {
481+ this . _highlightHandles ( this . _circleRadiusHandlesId , this . _getRadiusHandleCursorStyle ( event ) ) ;
457482 }
458483
459484 /**
@@ -482,15 +507,16 @@ class MapboxCircle {
482507
483508 /**
484509 * Highlight radius handles, disable panning and add mouse-move listener (emulating drag until mouse-up event).
510+ * @param {MapMouseEvent } event
485511 * @private
486512 */
487- _onRadiusHandlesMouseDown ( ) {
513+ _onRadiusHandlesMouseDown ( event ) {
488514 this . _radiusDragActive = true ;
489515 this . map . on ( 'mousemove' , this . _onRadiusHandlesMouseMove ) ;
490516 this . _suspendHandleListeners ( 'radius' ) ;
491517 this . map . once ( 'mouseup' , this . _onRadiusHandlesMouseUpOrMapMouseOut ) ;
492518 this . map . once ( 'mouseout' , this . _onRadiusHandlesMouseUpOrMapMouseOut ) ; // Deactivate drag if mouse leaves canvas.
493- this . _highlightHandles ( this . _circleRadiusHandlesId , 'ew-resize' ) ;
519+ this . _highlightHandles ( this . _circleRadiusHandlesId , this . _getRadiusHandleCursorStyle ( event ) ) ;
494520 }
495521
496522 /**
0 commit comments