@@ -550,77 +550,6 @@ describe('Test gl3d trace click/hover:', function() {
550550 . then ( done , done . fail ) ;
551551 } ) ;
552552
553- it ( '@gl should emit correct event data on unhover' , function ( done ) {
554- var _mock = Lib . extendDeep ( { } , mock2 ) ;
555- var x = 655 ;
556- var y = 221 ;
557-
558- function _hover ( ) {
559- mouseEvent ( 'mouseover' , x , y ) ;
560- }
561-
562- function _unhover ( ) {
563- return new Promise ( function ( resolve ) {
564- var x0 = x ;
565- var y0 = y ;
566- var initialElement = document . elementFromPoint ( x0 , y0 ) ;
567- var canceler = setInterval ( function ( ) {
568- x0 -= 2 ;
569- y0 -= 2 ;
570- mouseEvent ( 'mouseover' , x0 , y0 ) ;
571-
572- var nowElement = document . elementFromPoint ( x0 , y0 ) ;
573- if ( nowElement !== initialElement ) {
574- mouseEvent ( 'mouseout' , x0 , y0 , { element : initialElement } ) ;
575- }
576- } , 10 ) ;
577-
578- gd . on ( 'plotly_unhover' , function ( eventData ) {
579- clearInterval ( canceler ) ;
580- resolve ( eventData ) ;
581- } ) ;
582-
583- setTimeout ( function ( ) {
584- clearInterval ( canceler ) ;
585- resolve ( null ) ;
586- } , 350 ) ;
587- } ) ;
588- }
589-
590- Plotly . newPlot ( gd , _mock )
591- . then ( delay ( 20 ) )
592- . then ( function ( ) {
593- gd . on ( 'plotly_hover' , function ( eventData ) {
594- ptData = eventData . points [ 0 ] ;
595- } ) ;
596- gd . on ( 'plotly_unhover' , function ( eventData ) {
597- ptData = eventData . points [ 0 ] ;
598- } ) ;
599- } )
600- . then ( delay ( 20 ) )
601- . then ( _hover )
602- . then ( delay ( 20 ) )
603- . then ( function ( ) {
604- assertEventData ( 100.75 , - 102.63 , - 102.63 , 0 , 0 , {
605- 'marker.symbol' : 'circle' ,
606- 'marker.size' : 10 ,
607- 'marker.color' : 'blue' ,
608- 'marker.line.color' : 'black'
609- } ) ;
610- } )
611- . then ( _unhover )
612- . then ( delay ( 20 ) )
613- . then ( function ( ) {
614- assertEventData ( 100.75 , - 102.63 , - 102.63 , 0 , 0 , {
615- 'marker.symbol' : 'circle' ,
616- 'marker.size' : 10 ,
617- 'marker.color' : 'blue' ,
618- 'marker.line.color' : 'black'
619- } ) ;
620- } )
621- . then ( done , done . fail ) ;
622- } ) ;
623-
624553 it ( '@gl should display correct face colors' , function ( done ) {
625554 var fig = mesh3dcoloringMock ;
626555
@@ -1339,6 +1268,82 @@ describe('Test gl3d trace click/hover:', function() {
13391268 } ) ;
13401269 } ) ;
13411270 } ) ;
1271+
1272+ it ( '@gl should emit correct event data on unhover' , function ( done ) {
1273+ var _mock = Lib . extendDeep ( { } , mock2 ) ;
1274+ var x = 655 ;
1275+ var y = 221 ;
1276+
1277+ function _hover ( ) {
1278+ mouseEvent ( 'mouseover' , x , y ) ;
1279+ }
1280+
1281+ function _unhover ( ) {
1282+ return new Promise ( function ( resolve ) {
1283+ var x0 = x ;
1284+ var y0 = y ;
1285+ var initialElement = document . elementFromPoint ( x0 , y0 ) ;
1286+ var canceler = setInterval ( function ( ) {
1287+ x0 -= 2 ;
1288+ y0 -= 2 ;
1289+ mouseEvent ( 'mouseover' , x0 , y0 ) ;
1290+
1291+ var nowElement = document . elementFromPoint ( x0 , y0 ) ;
1292+ if ( nowElement !== initialElement ) {
1293+ mouseEvent ( 'mouseout' , x0 , y0 , { element : initialElement } ) ;
1294+ }
1295+ } , 10 ) ;
1296+
1297+ gd . on ( 'plotly_unhover' , function ( eventData ) {
1298+ clearInterval ( canceler ) ;
1299+ resolve ( eventData ) ;
1300+ } ) ;
1301+
1302+ setTimeout ( function ( ) {
1303+ clearInterval ( canceler ) ;
1304+ resolve ( null ) ;
1305+ } , 350 ) ;
1306+ } ) ;
1307+ }
1308+
1309+ Plotly . newPlot ( gd , _mock )
1310+ . then ( delay ( 20 ) )
1311+ . then ( function ( ) {
1312+ gd . on ( 'plotly_hover' , function ( eventData ) {
1313+ ptData = eventData . points [ 0 ] ;
1314+ } ) ;
1315+ gd . on ( 'plotly_unhover' , function ( eventData ) {
1316+ if ( eventData ) {
1317+ ptData = eventData . points [ 0 ] ;
1318+ } else {
1319+ ptData = { } ;
1320+ }
1321+ } ) ;
1322+ } )
1323+ . then ( delay ( 20 ) )
1324+ . then ( _hover )
1325+ . then ( delay ( 20 ) )
1326+ . then ( function ( ) {
1327+ assertEventData ( 100.75 , - 102.63 , - 102.63 , 0 , 0 , {
1328+ 'marker.symbol' : 'circle' ,
1329+ 'marker.size' : 10 ,
1330+ 'marker.color' : 'blue' ,
1331+ 'marker.line.color' : 'black'
1332+ } ) ;
1333+ } )
1334+ . then ( _unhover )
1335+ . then ( delay ( 20 ) )
1336+ . then ( function ( ) {
1337+ assertEventData ( 100.75 , - 102.63 , - 102.63 , 0 , 0 , {
1338+ 'marker.symbol' : 'circle' ,
1339+ 'marker.size' : 10 ,
1340+ 'marker.color' : 'blue' ,
1341+ 'marker.line.color' : 'black'
1342+ } ) ;
1343+ } )
1344+ . then ( done , done . fail ) ;
1345+ } ) ;
1346+
13421347} ) ;
13431348
13441349describe ( 'hover on traces with (x|y|z|u|v|w)hoverformat and valuehoverformat' , function ( ) {
0 commit comments