@@ -2272,13 +2272,6 @@ describe('Cartesian plots with css transforms', function() {
2272
2272
gd . style . transform = transformString ;
2273
2273
}
2274
2274
2275
- function recalculateInverse ( gd ) {
2276
- var m = Lib . inverseTransformMatrix ( Lib . getFullTransformMatrix ( gd ) ) ;
2277
- gd . _fullLayout . _inverseTransform = m ;
2278
- gd . _fullLayout . _inverseScaleX = Math . sqrt ( m [ 0 ] [ 0 ] * m [ 0 ] [ 0 ] + m [ 0 ] [ 1 ] * m [ 0 ] [ 1 ] + m [ 0 ] [ 2 ] * m [ 0 ] [ 2 ] ) ;
2279
- gd . _fullLayout . _inverseScaleY = Math . sqrt ( m [ 1 ] [ 0 ] * m [ 1 ] [ 0 ] + m [ 1 ] [ 1 ] * m [ 1 ] [ 1 ] + m [ 1 ] [ 2 ] * m [ 1 ] [ 2 ] ) ;
2280
- }
2281
-
2282
2275
function _drag ( start , end ) {
2283
2276
var localStart = _getLocalPos ( gd , start ) ;
2284
2277
var localEnd = _getLocalPos ( gd , end ) ;
@@ -2329,30 +2322,40 @@ describe('Cartesian plots with css transforms', function() {
2329
2322
margin : { l : 0 , t : 0 , r : 0 , b : 0 }
2330
2323
}
2331
2324
} ;
2332
- var transforms = [ 'scale(0.5)' ] ;
2333
2325
2334
- transforms . forEach ( function ( transform ) {
2326
+ [ {
2327
+ transform : 'scaleX(0.5)' ,
2328
+ hovered : 1 ,
2329
+ selected : { numPoints : 1 , selectedLabels : [ 'two' ] }
2330
+ } , {
2331
+ transform : 'scale(0.5)' ,
2332
+ hovered : 1 ,
2333
+ selected : { numPoints : 2 , selectedLabels : [ 'one' , 'two' ] }
2334
+ } , {
2335
+ transform : 'scale(0.25) translate(150px, 25%) scaleY(2)' ,
2336
+ hovered : 1 ,
2337
+ selected : { numPoints : 3 , selectedLabels : [ 'one' , 'two' , 'three' ] }
2338
+ } ] . forEach ( function ( t ) {
2339
+ var transform = t . transform ;
2340
+
2335
2341
it ( 'hover behaves correctly after css transform: ' + transform , function ( done ) {
2336
2342
function _hoverAndAssertEventOccurred ( point , label ) {
2337
2343
return _hover ( point )
2338
2344
. then ( function ( ) {
2339
- expect ( eventRecordings [ label ] ) . toBe ( 1 ) ;
2345
+ expect ( eventRecordings [ label ] ) . toBe ( t . hovered ) ;
2340
2346
} )
2341
2347
. then ( function ( ) {
2342
2348
_unhover ( point ) ;
2343
2349
} ) ;
2344
2350
}
2345
2351
2346
- Plotly . plot ( gd , Lib . extendDeep ( { } , mock ) )
2352
+ transformPlot ( gd , transform ) ;
2353
+ Plotly . newPlot ( gd , Lib . extendDeep ( { } , mock ) )
2347
2354
. then ( function ( ) {
2348
2355
gd . on ( 'plotly_hover' , function ( d ) {
2349
2356
eventRecordings [ d . points [ 0 ] . x ] = 1 ;
2350
2357
} ) ;
2351
2358
} )
2352
- . then ( function ( ) {
2353
- transformPlot ( gd , transform ) ;
2354
- recalculateInverse ( gd ) ;
2355
- } )
2356
2359
. then ( function ( ) { _hoverAndAssertEventOccurred ( points [ 0 ] , xLabels [ 0 ] ) ; } )
2357
2360
. then ( function ( ) { _hoverAndAssertEventOccurred ( points [ 1 ] , xLabels [ 1 ] ) ; } )
2358
2361
. then ( function ( ) { _hoverAndAssertEventOccurred ( points [ 2 ] , xLabels [ 2 ] ) ; } )
@@ -2381,7 +2384,7 @@ describe('Cartesian plots with css transforms', function() {
2381
2384
var size = [ endPos [ 0 ] - startPos [ 0 ] , endPos [ 1 ] - startPos [ 1 ] ] ;
2382
2385
var zb = d3 . select ( gd ) . select ( 'g.zoomlayer > path.zoombox' ) ;
2383
2386
var zoomboxRect = _getZoomlayerPathRect ( zb . attr ( 'd' ) ) ;
2384
- expect ( zoomboxRect . left ) . toBeCloseTo ( startPos [ 0 ] ) ;
2387
+ expect ( zoomboxRect . left ) . toBeCloseTo ( startPos [ 0 ] , - 1 ) ;
2385
2388
expect ( zoomboxRect . top ) . toBeCloseTo ( startPos [ 1 ] ) ;
2386
2389
expect ( zoomboxRect . width ) . toBeCloseTo ( size [ 0 ] ) ;
2387
2390
expect ( zoomboxRect . height ) . toBeCloseTo ( size [ 1 ] ) ;
@@ -2390,11 +2393,8 @@ describe('Cartesian plots with css transforms', function() {
2390
2393
var start = [ 50 , 50 ] ;
2391
2394
var end = [ 150 , 150 ] ;
2392
2395
2393
- Plotly . plot ( gd , Lib . extendDeep ( { } , mock ) )
2394
- . then ( function ( ) {
2395
- transformPlot ( gd , transform ) ;
2396
- recalculateInverse ( gd ) ;
2397
- } )
2396
+ transformPlot ( gd , transform ) ;
2397
+ Plotly . newPlot ( gd , Lib . extendDeep ( { } , mock ) )
2398
2398
. then ( function ( ) { _drag ( start , end ) ; } )
2399
2399
. then ( function ( ) {
2400
2400
_assertTransformedZoombox ( start , end ) ;
@@ -2421,19 +2421,16 @@ describe('Cartesian plots with css transforms', function() {
2421
2421
var start = [ 10 , 10 ] ;
2422
2422
var end = [ 200 , 200 ] ;
2423
2423
2424
- Plotly . plot ( gd , Lib . extendDeep ( { } , mock ) )
2425
- . then ( function ( ) {
2426
- transformPlot ( gd , transform ) ;
2427
- recalculateInverse ( gd ) ;
2428
- } )
2424
+ transformPlot ( gd , transform ) ;
2425
+ Plotly . newPlot ( gd , Lib . extendDeep ( { } , mock ) )
2429
2426
. then ( function ( ) {
2430
2427
return Plotly . relayout ( gd , 'dragmode' , 'select' ) ;
2431
2428
} )
2432
2429
. then ( function ( ) {
2433
2430
_dragRelease ( start , end ) ;
2434
2431
} )
2435
2432
. then ( function ( ) {
2436
- _assertSelected ( { numPoints : 2 , selectedLabels : [ 'one' , 'two' ] } ) ;
2433
+ _assertSelected ( t . selected ) ;
2437
2434
} )
2438
2435
. catch ( failTest )
2439
2436
. then ( done ) ;
0 commit comments