@@ -7,6 +7,7 @@ var DBLCLICKDELAY = require('../../../src/plot_api/plot_config').dfltConfig.doub
7
7
var d3Select = require ( '../../strict-d3' ) . select ;
8
8
var d3SelectAll = require ( '../../strict-d3' ) . selectAll ;
9
9
var createGraphDiv = require ( '../assets/create_graph_div' ) ;
10
+ var createShadowGraphDiv = require ( '../assets/create_shadow_graph_div' ) ;
10
11
var destroyGraphDiv = require ( '../assets/destroy_graph_div' ) ;
11
12
12
13
var mouseEvent = require ( '../assets/mouse_event' ) ;
@@ -1059,17 +1060,17 @@ describe('Test click interactions:', function() {
1059
1060
width : 600 ,
1060
1061
height : 600
1061
1062
} ) . then ( function ( ) {
1062
- expect ( gd . layout . xaxis . range ) . toBeCloseToArray ( [ 1 , 2.068 ] ) ;
1063
+ expect ( gd . layout . xaxis . range ) . toBeCloseToArray ( [ 1 , 2.068 ] , 1 ) ;
1063
1064
1064
1065
return doubleClick ( 300 , 300 ) ;
1065
1066
} )
1066
1067
. then ( function ( ) {
1067
- expect ( gd . layout . xaxis . range ) . toBeCloseToArray ( [ - 0.2019 , 3.249 ] ) ;
1068
+ expect ( gd . layout . xaxis . range ) . toBeCloseToArray ( [ - 0.2019 , 3.249 ] , 1 ) ;
1068
1069
1069
1070
return doubleClick ( 300 , 300 ) ;
1070
1071
} )
1071
1072
. then ( function ( ) {
1072
- expect ( gd . layout . xaxis . range ) . toBeCloseToArray ( [ 1 , 2.068 ] ) ;
1073
+ expect ( gd . layout . xaxis . range ) . toBeCloseToArray ( [ 1 , 2.068 ] , 1 ) ;
1073
1074
} )
1074
1075
. then ( done , done . fail ) ;
1075
1076
} ) ;
@@ -1164,6 +1165,56 @@ describe('Test click interactions:', function() {
1164
1165
} ) ;
1165
1166
} ) ;
1166
1167
1168
+ describe ( 'Click events in Shadow DOM' , function ( ) {
1169
+ afterEach ( destroyGraphDiv ) ;
1170
+
1171
+ function fig ( ) {
1172
+ var x = [ ] ;
1173
+ var y = [ ] ;
1174
+ for ( var i = 0 ; i <= 20 ; i ++ ) {
1175
+ for ( var j = 0 ; j <= 20 ; j ++ ) {
1176
+ x . push ( i ) ;
1177
+ y . push ( j ) ;
1178
+ }
1179
+ }
1180
+ return {
1181
+ data : [ { x : x , y : y , mode : 'markers' } ] ,
1182
+ layout : {
1183
+ width : 400 ,
1184
+ height : 400 ,
1185
+ margin : { l : 100 , r : 100 , t : 100 , b : 100 } ,
1186
+ xaxis : { range : [ 0 , 20 ] } ,
1187
+ yaxis : { range : [ 0 , 20 ] } ,
1188
+ }
1189
+ } ;
1190
+ }
1191
+
1192
+ it ( 'should select the same point in regular and shadow DOM' , function ( done ) {
1193
+ var clickData ;
1194
+ var clickX = 120 ;
1195
+ var clickY = 150 ;
1196
+ var expectedX = 2 ; // counts up 1 every 10px from 0 at 100px
1197
+ var expectedY = 15 ; // counts down 1 every 10px from 20 at 100px
1198
+
1199
+ function check ( gd ) {
1200
+ gd . on ( 'plotly_click' , function ( event ) { clickData = event ; } ) ;
1201
+ click ( clickX , clickY ) ;
1202
+ expect ( clickData . points . length ) . toBe ( 1 ) ;
1203
+ var pt = clickData . points [ 0 ] ;
1204
+ expect ( pt . x ) . toBe ( expectedX ) ;
1205
+ expect ( pt . y ) . toBe ( expectedY ) ;
1206
+ clickData = null ;
1207
+ }
1208
+
1209
+ Plotly . newPlot ( createGraphDiv ( ) , fig ( ) )
1210
+ . then ( check )
1211
+ . then ( destroyGraphDiv )
1212
+ . then ( function ( ) { return Plotly . newPlot ( createShadowGraphDiv ( ) , fig ( ) ) } )
1213
+ . then ( check )
1214
+ . then ( done , done . fail ) ;
1215
+ } ) ;
1216
+ } ) ;
1217
+
1167
1218
1168
1219
describe ( 'dragbox' , function ( ) {
1169
1220
afterEach ( destroyGraphDiv ) ;
0 commit comments