@@ -557,11 +557,11 @@ drawing.steps = function(shape) {
557
557
} ;
558
558
559
559
// off-screen svg render testing element, shared by the whole page
560
- // uses the id 'js-plotly-tester' and stores it in gd._tester
560
+ // uses the id 'js-plotly-tester' and stores it in drawing.tester
561
561
// makes a hash of cached text items in tester.node()._cache
562
562
// so we can add references to rendered text (including all info
563
563
// needed to fully determine its bounding rect)
564
- drawing . makeTester = function ( gd ) {
564
+ drawing . makeTester = function ( ) {
565
565
var tester = d3 . select ( 'body' )
566
566
. selectAll ( '#js-plotly-tester' )
567
567
. data ( [ 0 ] ) ;
@@ -594,16 +594,16 @@ drawing.makeTester = function(gd) {
594
594
tester . node ( ) . _cache = { } ;
595
595
}
596
596
597
- gd . _tester = tester ;
598
- gd . _testref = testref ;
597
+ drawing . tester = tester ;
598
+ drawing . testref = testref ;
599
599
} ;
600
600
601
601
// use our offscreen tester to get a clientRect for an element,
602
602
// in a reference frame where it isn't translated and its anchor
603
603
// point is at (0,0)
604
604
// always returns a copy of the bbox, so the caller can modify it safely
605
- var savedBBoxes = [ ] ,
606
- maxSavedBBoxes = 10000 ;
605
+ var savedBBoxes = [ ] ;
606
+ var maxSavedBBoxes = 10000 ;
607
607
608
608
drawing . bBox = function ( node ) {
609
609
// cache elements we've already measured so we don't have to
@@ -613,14 +613,13 @@ drawing.bBox = function(node) {
613
613
return Lib . extendFlat ( { } , savedBBoxes [ saveNum . value ] ) ;
614
614
}
615
615
616
- if ( ! drawing . test3 ) {
617
- drawing . test3 = d3 . select ( '#js-plotly-tester' ) ;
618
- drawing . tester = drawing . test3 . node ( ) ;
619
- }
616
+ var tester3 = drawing . tester ;
617
+ var tester = tester3 . node ( ) ;
620
618
621
619
// copy the node to test into the tester
622
620
var testNode = node . cloneNode ( true ) ;
623
- drawing . tester . appendChild ( testNode ) ;
621
+ tester . appendChild ( testNode ) ;
622
+
624
623
// standardize its position... do we really want to do this?
625
624
d3 . select ( testNode ) . attr ( {
626
625
x : 0 ,
@@ -629,20 +628,19 @@ drawing.bBox = function(node) {
629
628
} ) ;
630
629
631
630
var testRect = testNode . getBoundingClientRect ( ) ;
632
- if ( ! drawing . refRect ) {
633
- drawing . refRect = drawing . test3 . select ( '.js-reference-point' )
634
- . node ( ) . getBoundingClientRect ( ) ;
635
- }
631
+ var refRect = drawing . testref
632
+ . node ( )
633
+ . getBoundingClientRect ( ) ;
636
634
637
- drawing . tester . removeChild ( testNode ) ;
635
+ tester . removeChild ( testNode ) ;
638
636
639
637
var bb = {
640
638
height : testRect . height ,
641
639
width : testRect . width ,
642
- left : testRect . left - drawing . refRect . left ,
643
- top : testRect . top - drawing . refRect . top ,
644
- right : testRect . right - drawing . refRect . left ,
645
- bottom : testRect . bottom - drawing . refRect . top
640
+ left : testRect . left - refRect . left ,
641
+ top : testRect . top - refRect . top ,
642
+ right : testRect . right - refRect . left ,
643
+ bottom : testRect . bottom - refRect . top
646
644
} ;
647
645
648
646
// make sure we don't have too many saved boxes,
0 commit comments