@@ -750,6 +750,161 @@ describe('Test gl3d trace click/hover:', function() {
750750 . then ( done ) ;
751751 } ) ;
752752
753+ function scroll ( target , amt ) {
754+ return new Promise ( function ( resolve ) {
755+ target . dispatchEvent ( new WheelEvent ( 'wheel' , { deltaY : amt || 1 , cancelable : true } ) ) ;
756+ setTimeout ( resolve , 0 ) ;
757+ } ) ;
758+ }
759+
760+ var _scroll = function ( ) {
761+ var sceneTarget = gd . querySelector ( '.svg-container .gl-container #scene canvas' ) ;
762+ return scroll ( sceneTarget , - 1 ) ;
763+ } ;
764+
765+ it ( '@gl should pick correct points after orthographic scroll zoom - mesh3d case' , function ( done ) {
766+ var fig = {
767+ data : [ {
768+ x : [ 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ] ,
769+ y : [ 0 , 0 , 1 , 1 , 0 , 0 , 1 , 1 ] ,
770+ z : [ 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 ] ,
771+ i : [ 0 , 3 , 4 , 7 , 0 , 6 , 1 , 7 , 0 , 5 , 2 , 7 ] ,
772+ j : [ 1 , 2 , 5 , 6 , 2 , 4 , 3 , 5 , 4 , 1 , 6 , 3 ] ,
773+ k : [ 3 , 0 , 7 , 4 , 6 , 0 , 7 , 1 , 5 , 0 , 7 , 2 ] ,
774+ vertexcolor : [ '#000' , '#00F' , '#0F0' , '#0FF' , '#F00' , '#F0F' , '#FF0' , '#FFF' ] ,
775+ hovertemplate : 'x: %{x}<br>y: %{y}<br>z: %{z}<br>vertex color: %{vertexcolor}' ,
776+ flatshading : true ,
777+ type : 'mesh3d' ,
778+ name : 'vertex color'
779+ } ] ,
780+ layout : {
781+ width : 600 ,
782+ height : 400 ,
783+ scene : {
784+ camera : {
785+ projection : { type : 'orthographic' } ,
786+ eye : { x : 1 , y : 1 , z : 1 }
787+ }
788+ }
789+ } ,
790+ config : {
791+ scrollZoom : 'gl3d'
792+ }
793+ } ;
794+
795+ Plotly . newPlot ( gd , fig )
796+ . then ( delay ( 20 ) )
797+ . then ( function ( ) { mouseEvent ( 'mouseover' , 300 , 200 ) ; } )
798+ . then ( delay ( 20 ) )
799+ . then ( function ( ) {
800+ assertHoverText (
801+ 'x: 1' ,
802+ 'y: 1' ,
803+ 'z: 1' ,
804+ 'vertex color: #FFF' ,
805+ 'vertex color'
806+ ) ;
807+ } )
808+ . then ( _scroll )
809+ . then ( _scroll )
810+ . then ( delay ( 20 ) )
811+ . then ( function ( ) { mouseEvent ( 'mouseover' , 300 , 100 ) ; } )
812+ . then ( delay ( 20 ) )
813+ . then ( function ( ) {
814+ assertHoverText (
815+ 'x: 0' ,
816+ 'y: 0' ,
817+ 'z: 1' ,
818+ 'vertex color: #F00' ,
819+ 'vertex color'
820+ ) ;
821+ } )
822+ . then ( delay ( 20 ) )
823+ . then ( function ( ) { mouseEvent ( 'mouseover' , 300 , 300 ) ; } )
824+ . then ( delay ( 20 ) )
825+ . then ( function ( ) {
826+ assertHoverText (
827+ 'x: 1' ,
828+ 'y: 1' ,
829+ 'z: 0' ,
830+ 'vertex color: #0FF' ,
831+ 'vertex color'
832+ ) ;
833+ } )
834+ . catch ( failTest )
835+ . then ( done ) ;
836+ } ) ;
837+
838+ it ( '@gl should pick correct points after orthographic scroll zoom - scatter3d case' , function ( done ) {
839+ var fig = {
840+ data : [ {
841+ x : [ 0 , 1 , 0 , 1 , 0 , 1 , 0 , 1 ] ,
842+ y : [ 0 , 0 , 1 , 1 , 0 , 0 , 1 , 1 ] ,
843+ z : [ 0 , 0 , 0 , 0 , 1 , 1 , 1 , 1 ] ,
844+ marker : { color : [ '#000' , '#00F' , '#0F0' , '#0FF' , '#F00' , '#F0F' , '#FF0' , '#FFF' ] } ,
845+ hovertemplate : 'x: %{x}<br>y: %{y}<br>z: %{z}<br>marker color: %{marker.color}' ,
846+ type : 'scatter3d' ,
847+ mode : 'marker' ,
848+ name : 'marker color'
849+ } ] ,
850+ layout : {
851+ width : 600 ,
852+ height : 400 ,
853+ scene : {
854+ camera : {
855+ projection : { type : 'orthographic' } ,
856+ eye : { x : 1 , y : 1 , z : 1 }
857+ }
858+ }
859+ } ,
860+ config : {
861+ scrollZoom : 'gl3d'
862+ }
863+ } ;
864+
865+ Plotly . newPlot ( gd , fig )
866+ . then ( delay ( 20 ) )
867+ . then ( function ( ) { mouseEvent ( 'mouseover' , 300 , 200 ) ; } )
868+ . then ( delay ( 20 ) )
869+ . then ( function ( ) {
870+ assertHoverText (
871+ 'x: 1' ,
872+ 'y: 1' ,
873+ 'z: 1' ,
874+ 'marker color: #FFF' ,
875+ 'marker color'
876+ ) ;
877+ } )
878+ . then ( _scroll )
879+ . then ( _scroll )
880+ . then ( delay ( 20 ) )
881+ . then ( function ( ) { mouseEvent ( 'mouseover' , 300 , 100 ) ; } )
882+ . then ( delay ( 20 ) )
883+ . then ( function ( ) {
884+ assertHoverText (
885+ 'x: 0' ,
886+ 'y: 0' ,
887+ 'z: 1' ,
888+ 'marker color: #F00' ,
889+ 'marker color'
890+ ) ;
891+ } )
892+ . then ( delay ( 20 ) )
893+ . then ( function ( ) { mouseEvent ( 'mouseover' , 300 , 300 ) ; } )
894+ . then ( delay ( 20 ) )
895+ . then ( function ( ) {
896+ assertHoverText (
897+ 'x: 1' ,
898+ 'y: 1' ,
899+ 'z: 0' ,
900+ 'marker color: #0FF' ,
901+ 'marker color'
902+ ) ;
903+ } )
904+ . catch ( failTest )
905+ . then ( done ) ;
906+ } ) ;
907+
753908 it ( '@gl should pick latest & closest points on hover if two points overlap' , function ( done ) {
754909 var _mock = Lib . extendDeep ( { } , mock4 ) ;
755910
0 commit comments