@@ -96,22 +96,23 @@ export function mouseUp(chart, event) {
9696 }
9797
9898 removeHandler ( chart . canvas , 'mousemove' , chart ) ;
99- const zoomOptions = state . options . zoom ;
100- const rect = computeDragRect ( chart , zoomOptions . mode , state . dragStart , event ) ;
101- const { width : dragDistanceX , height : dragDistanceY } = rect ;
99+ const { mode, onZoomComplete, drag : { threshold = 0 } } = state . options . zoom ;
100+ const rect = computeDragRect ( chart , mode , state . dragStart , event ) ;
101+ const distanceX = directionEnabled ( mode , 'x' , chart ) ? rect . width : 0 ;
102+ const distanceY = directionEnabled ( mode , 'y' , chart ) ? rect . height : 0 ;
103+ const distance = Math . sqrt ( distanceX * distanceX + distanceY * distanceY ) ;
102104
103105 // Remove drag start and end before chart update to stop drawing selected area
104106 state . dragStart = state . dragEnd = null ;
105107
106- const zoomThreshold = zoomOptions . drag . threshold || 0 ;
107- if ( dragDistanceX <= zoomThreshold && dragDistanceY <= zoomThreshold ) {
108+ if ( distance <= threshold ) {
108109 return ;
109110 }
110111
111112 zoomRect ( chart , { x : rect . left , y : rect . top } , { x : rect . right , y : rect . bottom } , 'zoom' ) ;
112113
113114 setTimeout ( ( ) => ( state . dragging = false ) , 500 ) ;
114- call ( zoomOptions . onZoomComplete , [ { chart} ] ) ;
115+ call ( onZoomComplete , [ { chart} ] ) ;
115116}
116117
117118function wheelPreconditions ( chart , event , zoomOptions ) {
0 commit comments