@@ -15,6 +15,7 @@ var Fx = require('../../components/fx');
15
15
var Lib = require ( '../../lib' ) ;
16
16
var dragElement = require ( '../../components/dragelement' ) ;
17
17
var prepSelect = require ( '../cartesian/select' ) . prepSelect ;
18
+ var selectOnClick = require ( '../cartesian/select' ) . selectOnClick ;
18
19
var constants = require ( './constants' ) ;
19
20
var layoutAttributes = require ( './layout_attributes' ) ;
20
21
var createMapboxLayer = require ( './layers' ) ;
@@ -176,15 +177,6 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
176
177
Fx . hover ( gd , evt , self . id ) ;
177
178
} ) ;
178
179
179
- map . on ( 'click' , function ( evt ) {
180
- // TODO: this does not support right-click. If we want to support it, we
181
- // would likely need to change mapbox to use dragElement instead of straight
182
- // mapbox event binding. Or perhaps better, make a simple wrapper with the
183
- // right mousedown, mousemove, and mouseup handlers just for a left/right click
184
- // pie would use this too.
185
- Fx . click ( gd , evt . originalEvent ) ;
186
- } ) ;
187
-
188
180
function unhover ( ) {
189
181
Fx . loneUnhover ( fullLayout . _toppaper ) ;
190
182
}
@@ -221,11 +213,17 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
221
213
gd . emit ( 'plotly_relayout' , evtData ) ;
222
214
}
223
215
224
- // define clear select on map creation, to keep one ref per map,
216
+ // define event handlers on map creation, to keep one ref per map,
225
217
// so that map.on / map.off in updateFx works as expected
226
218
self . clearSelect = function ( ) {
227
219
gd . _fullLayout . _zoomlayer . selectAll ( '.select-outline' ) . remove ( ) ;
228
220
} ;
221
+
222
+ self . onClickInPan = function ( evt ) {
223
+ // TODO Add condition evaluating clickmode attr when it has been introduced
224
+ selectOnClick ( gd , 1 , evt . originalEvent , [ self . xaxis ] , [ self . yaxis ] , undefined , self . id ) ;
225
+ Fx . click ( gd , evt . originalEvent ) ;
226
+ } ;
229
227
} ;
230
228
231
229
proto . updateMap = function ( calcData , fullLayout , resolve , reject ) {
@@ -404,10 +402,19 @@ proto.updateFx = function(fullLayout) {
404
402
} ;
405
403
406
404
dragElement . init ( dragOptions ) ;
405
+
406
+ map . off ( 'click' , self . onClickInPan ) ;
407
407
} else {
408
408
map . dragPan . enable ( ) ;
409
409
map . off ( 'zoomstart' , self . clearSelect ) ;
410
410
self . div . onmousedown = null ;
411
+
412
+ // TODO: this does not support right-click. If we want to support it, we
413
+ // would likely need to change mapbox to use dragElement instead of straight
414
+ // mapbox event binding. Or perhaps better, make a simple wrapper with the
415
+ // right mousedown, mousemove, and mouseup handlers just for a left/right click
416
+ // pie would use this too.
417
+ map . on ( 'click' , self . onClickInPan ) ;
411
418
}
412
419
} ;
413
420
0 commit comments