@@ -1076,6 +1076,92 @@ describe('Test polar interactions:', function() {
1076
1076
. catch ( failTest )
1077
1077
. then ( done ) ;
1078
1078
} ) ;
1079
+
1080
+ describe ( '@gl should update scene during drag interactions on radial and angular drag area' , function ( ) {
1081
+ var objs = [ 'scatter2d' , 'line2d' ] ;
1082
+ var scene , gl , nTraces ;
1083
+
1084
+ function _dragRadial ( ) {
1085
+ var node = d3 . select ( '.polar > .draglayer > .radialdrag' ) . node ( ) ;
1086
+ var p0 = [ 375 , 200 ] ;
1087
+ var dp = [ - 50 , 0 ] ;
1088
+ return drag ( node , dp [ 0 ] , dp [ 1 ] , null , p0 [ 0 ] , p0 [ 1 ] , 2 ) ;
1089
+ }
1090
+
1091
+ function _dragAngular ( ) {
1092
+ var node = d3 . select ( '.polar > .draglayer > .angulardrag' ) . node ( ) ;
1093
+ var p0 = [ 350 , 150 ] ;
1094
+ var dp = [ - 20 , 20 ] ;
1095
+ return drag ( node , dp [ 0 ] , dp [ 1 ] , null , p0 [ 0 ] , p0 [ 1 ] ) ;
1096
+ }
1097
+
1098
+ // once on drag, once on mouseup relayout
1099
+ function _assert ( ) {
1100
+ expect ( gl . clear ) . toHaveBeenCalledTimes ( 2 ) ;
1101
+ gl . clear . calls . reset ( ) ;
1102
+
1103
+ objs . forEach ( function ( o ) {
1104
+ if ( scene [ o ] ) {
1105
+ expect ( scene [ o ] . draw ) . toHaveBeenCalledTimes ( 2 * nTraces ) ;
1106
+ scene [ o ] . draw . calls . reset ( ) ;
1107
+ }
1108
+ } ) ;
1109
+ }
1110
+
1111
+ var specs = [ {
1112
+ desc : 'scatter marker case' ,
1113
+ // mode: 'markers' by default
1114
+ } , {
1115
+ desc : 'line case' ,
1116
+ // start with lines to lock down fix for #2888
1117
+ patch : function ( fig ) {
1118
+ fig . data . forEach ( function ( trace ) { trace . mode = 'lines' ; } ) ;
1119
+ }
1120
+ } , {
1121
+ desc : 'line & markers case' ,
1122
+ patch : function ( fig ) {
1123
+ fig . data . forEach ( function ( trace ) { trace . mode = 'markers+lines' ; } ) ;
1124
+ }
1125
+ } ] ;
1126
+
1127
+ specs . forEach ( function ( s ) {
1128
+ it ( '- ' + s . desc , function ( done ) {
1129
+ var fig = Lib . extendDeep ( { } , require ( '@mocks/glpolar_scatter.json' ) ) ;
1130
+ scene = null ;
1131
+ gl = null ;
1132
+
1133
+ fig . layout . hovermode = false ;
1134
+ fig . layout . width = 400 ;
1135
+ fig . layout . height = 400 ;
1136
+ fig . layout . margin = { l : 50 , t : 50 , b : 50 , r : 50 } ;
1137
+
1138
+ if ( s . patch ) s . patch ( fig ) ;
1139
+ nTraces = fig . data . length ;
1140
+
1141
+ Plotly . newPlot ( gd , fig ) . then ( function ( ) {
1142
+ scene = gd . _fullLayout . polar . _subplot . _scene ;
1143
+
1144
+ objs . forEach ( function ( o ) {
1145
+ if ( scene [ o ] ) {
1146
+ spyOn ( scene [ o ] , 'draw' ) . and . callThrough ( ) ;
1147
+ if ( ! gl ) {
1148
+ // all objects have the same _gl ref,
1149
+ // spy on it just once
1150
+ gl = scene [ o ] . regl . _gl ;
1151
+ spyOn ( gl , 'clear' ) . and . callThrough ( ) ;
1152
+ }
1153
+ }
1154
+ } ) ;
1155
+ } )
1156
+ . then ( function ( ) { return _dragRadial ( ) ; } )
1157
+ . then ( _assert )
1158
+ . then ( function ( ) { return _dragAngular ( ) ; } )
1159
+ . then ( _assert )
1160
+ . catch ( failTest )
1161
+ . then ( done ) ;
1162
+ } ) ;
1163
+ } ) ;
1164
+ } ) ;
1079
1165
} ) ;
1080
1166
1081
1167
describe ( 'Test polar *gridshape linear* interactions' , function ( ) {
0 commit comments