@@ -3712,11 +3712,7 @@ function purge(gd) {
37123712function makePlotFramework ( gd ) {
37133713 var gd3 = d3 . select ( gd ) ;
37143714 var fullLayout = gd . _fullLayout ;
3715- if ( fullLayout . _inverseTransform === undefined ) {
3716- var m = fullLayout . _inverseTransform = Lib . inverseTransformMatrix ( Lib . getFullTransformMatrix ( gd ) ) ;
3717- fullLayout . _inverseScaleX = Math . sqrt ( m [ 0 ] [ 0 ] * m [ 0 ] [ 0 ] + m [ 0 ] [ 1 ] * m [ 0 ] [ 1 ] + m [ 0 ] [ 2 ] * m [ 0 ] [ 2 ] ) ;
3718- fullLayout . _inverseScaleY = Math . sqrt ( m [ 1 ] [ 0 ] * m [ 1 ] [ 0 ] + m [ 1 ] [ 1 ] * m [ 1 ] [ 1 ] + m [ 1 ] [ 2 ] * m [ 1 ] [ 2 ] ) ;
3719- }
3715+ recalculateTransformInverseIfNecessary ( gd ) ;
37203716
37213717 // Plot container
37223718 fullLayout . _container = gd3 . selectAll ( '.plot-container' ) . data ( [ 0 ] ) ;
@@ -3856,9 +3852,25 @@ function makePlotFramework(gd) {
38563852 . style ( 'top' , '0px' )
38573853 . style ( 'right' , '0px' ) ;
38583854
3855+ fullLayout . _lastBBox = gd . getBoundingClientRect ( ) ;
3856+
38593857 gd . emit ( 'plotly_framework' ) ;
38603858}
38613859
3860+ // determines if the graph div requires a recalculation of its inverse matrix transforms by comparing old + new bounding boxes.
3861+ function recalculateTransformInverseIfNecessary ( gd , newBBox = null ) {
3862+ gd = Lib . getGraphDiv ( gd ) ;
3863+ var fullLayout = gd . _fullLayout ;
3864+ if ( ! newBBox )
3865+ newBBox = gd . getBoundingClientRect ( ) ;
3866+ if ( Lib . domRectsAreEqual ( newBBox , fullLayout . _lastBBox ) )
3867+ return ;
3868+ var m = fullLayout . _inverseTransform = Lib . inverseTransformMatrix ( Lib . getFullTransformMatrix ( gd ) ) ;
3869+ fullLayout . _inverseScaleX = Math . sqrt ( m [ 0 ] [ 0 ] * m [ 0 ] [ 0 ] + m [ 0 ] [ 1 ] * m [ 0 ] [ 1 ] + m [ 0 ] [ 2 ] * m [ 0 ] [ 2 ] ) ;
3870+ fullLayout . _inverseScaleY = Math . sqrt ( m [ 1 ] [ 0 ] * m [ 1 ] [ 0 ] + m [ 1 ] [ 1 ] * m [ 1 ] [ 1 ] + m [ 1 ] [ 2 ] * m [ 1 ] [ 2 ] ) ;
3871+ fullLayout . _lastBBox = gd . getBoundingClientRect ( ) ;
3872+ }
3873+
38623874exports . animate = animate ;
38633875exports . addFrames = addFrames ;
38643876exports . deleteFrames = deleteFrames ;
@@ -3886,4 +3898,6 @@ exports._guiRelayout = guiEdit(relayout);
38863898exports . _guiRestyle = guiEdit ( restyle ) ;
38873899exports . _guiUpdate = guiEdit ( update ) ;
38883900
3901+ exports . recalculateTransformInverseIfNecessary = recalculateTransformInverseIfNecessary ;
3902+
38893903exports . _storeDirectGUIEdit = _storeDirectGUIEdit ;
0 commit comments