@@ -159,6 +159,8 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
159
159
}
160
160
}
161
161
162
+ var direction = fullLayout . selectdirection ;
163
+
162
164
dragOptions . moveFn = function ( dx0 , dy0 ) {
163
165
x1 = Math . max ( 0 , Math . min ( pw , dx0 + x0 ) ) ;
164
166
y1 = Math . max ( 0 , Math . min ( ph , dy0 + y0 ) ) ;
@@ -167,7 +169,17 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
167
169
dy = Math . abs ( y1 - y0 ) ;
168
170
169
171
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' ) {
171
183
// horizontal motion: make a vertical box
172
184
currentPolygon = [ [ x0 , 0 ] , [ x0 , ph ] , [ x1 , ph ] , [ x1 , 0 ] ] ;
173
185
currentPolygon . xmin = Math . min ( x0 , x1 ) ;
@@ -181,7 +193,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
181
193
'h4v' + ( 2 * MINSELECT ) + 'h-4Z' ) ;
182
194
183
195
}
184
- else if ( dx < Math . min ( dy * 0.6 , MINSELECT ) ) {
196
+ else if ( direction === 'v' ) {
185
197
// vertical motion: make a horizontal box
186
198
currentPolygon = [ [ 0 , y0 ] , [ 0 , y1 ] , [ pw , y1 ] , [ pw , y0 ] ] ;
187
199
currentPolygon . xmin = Math . min ( 0 , pw ) ;
@@ -193,7 +205,7 @@ module.exports = function prepSelect(e, startX, startY, dragOptions, mode) {
193
205
'M' + ( x0 - MINSELECT ) + ',' + ( currentPolygon . ymax - 1 ) +
194
206
'v4h' + ( 2 * MINSELECT ) + 'v-4Z' ) ;
195
207
}
196
- else {
208
+ else if ( direction === 'd' ) {
197
209
// diagonal motion
198
210
currentPolygon = [ [ x0 , y0 ] , [ x0 , y1 ] , [ x1 , y1 ] , [ x1 , y0 ] ] ;
199
211
currentPolygon . xmin = Math . min ( x0 , x1 ) ;
0 commit comments