@@ -159,6 +159,8 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
159159 }
160160 }
161161
162+ var direction = fullLayout . selectdirection ;
163+
162164 dragOptions . moveFn = function ( dx0 , dy0 ) {
163165 x1 = Math . max ( 0 , Math . min ( pw , dx0 + x0 ) ) ;
164166 y1 = Math . max ( 0 , Math . min ( ph , dy0 + y0 ) ) ;
@@ -167,7 +169,17 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
167169 dy = Math . abs ( y1 - y0 ) ;
168170
169171 if ( mode === 'select' ) {
170- if ( dy < Math . min ( dx * 0.6 , MINSELECT ) ) {
172+
173+ if ( fullLayout . selectdirection === 'any' ) {
174+ if ( dy < Math . min ( dx * 0.6 , MINSELECT ) ) direction = 'h' ;
175+ else if ( dx < Math . min ( dy * 0.6 , MINSELECT ) ) direction = 'v' ;
176+ else direction = 'd' ;
177+ }
178+ else {
179+ direction = fullLayout . selectdirection ;
180+ }
181+
182+ if ( direction === 'h' ) {
171183 // horizontal motion: make a vertical box
172184 currentPolygon = [ [ x0 , 0 ] , [ x0 , ph ] , [ x1 , ph ] , [ x1 , 0 ] ] ;
173185 currentPolygon . xmin = Math . min ( x0 , x1 ) ;
@@ -181,7 +193,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
181193 'h4v' + ( 2 * MINSELECT ) + 'h-4Z' ) ;
182194
183195 }
184- else if ( dx < Math . min ( dy * 0.6 , MINSELECT ) ) {
196+ else if ( direction === 'v' ) {
185197 // vertical motion: make a horizontal box
186198 currentPolygon = [ [ 0 , y0 ] , [ 0 , y1 ] , [ pw , y1 ] , [ pw , y0 ] ] ;
187199 currentPolygon . xmin = Math . min ( 0 , pw ) ;
@@ -193,7 +205,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
193205 'M' + ( x0 - MINSELECT ) + ',' + ( currentPolygon . ymax - 1 ) +
194206 'v4h' + ( 2 * MINSELECT ) + 'v-4Z' ) ;
195207 }
196- else {
208+ else if ( direction === 'd' ) {
197209 // diagonal motion
198210 currentPolygon = [ [ x0 , y0 ] , [ x0 , y1 ] , [ x1 , y1 ] , [ x1 , y0 ] ] ;
199211 currentPolygon . xmin = Math . min ( x0 , x1 ) ;
0 commit comments