@@ -1617,6 +1617,56 @@ describe('annotation effects', function() {
1617
1617
. catch ( failTest )
1618
1618
. then ( done ) ;
1619
1619
} ) ;
1620
+
1621
+ it ( 'should remove annotations if offscreen during axis drag' , function ( done ) {
1622
+ gd = createGraphDiv ( ) ;
1623
+
1624
+ function _assert ( msg , exp ) {
1625
+ return function ( ) {
1626
+ expect ( gd . _dragging ) . toBe ( exp . dragging , 'is during drag| ' + msg ) ;
1627
+ expect ( Boolean ( textDrag ( ) ) ) . toBe ( exp . onScreen , 'is annotation on screen| ' + msg ) ;
1628
+ } ;
1629
+ }
1630
+
1631
+ Plotly . plot ( gd , [ {
1632
+ x : [ 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 ] ,
1633
+ y : [ 0 , 4 , 5 , 1 , 2 , 2 , 3 , 4 , 2 ] ,
1634
+ } ] , {
1635
+ dragmode : 'pan' ,
1636
+ width : 500 , height : 500 ,
1637
+ annotations : [ {
1638
+ x : 2 , y : 5 ,
1639
+ xref : 'x' , yref : 'y' ,
1640
+ text : 'Annotation Text' ,
1641
+ arrowhead : 7 ,
1642
+ ax : 0 , ay : - 40
1643
+ } ]
1644
+ } )
1645
+ . then ( _assert ( 'base' , {
1646
+ dragging : undefined ,
1647
+ onScreen : true
1648
+ } ) )
1649
+ . then ( function ( ) {
1650
+ var fns = drag . makeFns ( { pos0 : [ 250 , 250 ] , posN : [ 500 , 250 ] } ) ;
1651
+ return fns . start ( )
1652
+ . then ( _assert ( 'during drag offscreen' , {
1653
+ dragging : true ,
1654
+ onScreen : false
1655
+ } ) )
1656
+ . then ( fns . end ) ;
1657
+ } )
1658
+ . then ( function ( ) {
1659
+ var fns = drag . makeFns ( { pos0 : [ 250 , 250 ] , posN : [ 0 , 250 ] } ) ;
1660
+ return fns . start ( )
1661
+ . then ( _assert ( 'during drag back onscreen' , {
1662
+ dragging : true ,
1663
+ onScreen : true
1664
+ } ) )
1665
+ . then ( fns . end ) ;
1666
+ } )
1667
+ . catch ( failTest )
1668
+ . then ( done ) ;
1669
+ } ) ;
1620
1670
} ) ;
1621
1671
1622
1672
describe ( 'animating annotations' , function ( ) {
0 commit comments