@@ -13,7 +13,7 @@ var createLine = require('regl-line2d');
1313var createError = require ( 'regl-error2d' ) ;
1414var cluster = require ( 'point-cluster' ) ;
1515var arrayRange = require ( 'array-range' ) ;
16- var Text = require ( 'gl-text' ) ;
16+ var Text = require ( '../../../../ gl-text/index ' ) ;
1717
1818var Registry = require ( '../../registry' ) ;
1919var Lib = require ( '../../lib' ) ;
@@ -861,17 +861,21 @@ function selectPoints(searchInfo, polygon) {
861861
862862 // update texts selection
863863 if ( hasText ) {
864- var textOptions = { } ;
864+ var textOptions = Lib . extendFlat ( { } , scene . textOptions [ stash . index ] ) ;
865865 if ( els && unels ) {
866866 if ( els ) {
867867 applyTextoption ( textOptions , els , scene . selectedOptions [ stash . index ] ) ;
868868 }
869869 if ( unels ) {
870870 applyTextoption ( textOptions , unels , scene . unselectedOptions [ stash . index ] ) ;
871+ if ( ! scene . unselectedOptions [ stash . index ] . opacity ) {
872+ applyTextoption ( textOptions , unels , { opacity : 1 } ) ;
873+ }
871874 }
872875 }
873876 else {
874- // TODO: reset unselected style properly
877+ applyTextoption ( textOptions , unels , { opacity : 1 } ) ;
878+ applyTextoption ( textOptions , unels , scene . textOptions [ stash . index ] ) ;
875879 }
876880
877881 scene . glText [ stash . index ] . update ( textOptions ) ;
@@ -883,12 +887,11 @@ function selectPoints(searchInfo, polygon) {
883887 var el = els [ i ] ;
884888 if ( selOptions . textfont ) {
885889 if ( selOptions . textfont . color ) {
886- if ( ! textOptions . color ) textOptions . color = [ ] ;
890+ textOptions . color = toArray ( textOptions . color ) ;
887891 textOptions . color [ el ] = selOptions . textfont . color ;
888892 }
889893 if ( selOptions . textfont . family || selOptions . textfont . size ) {
890- if ( ! textOptions . font ) textOptions . font = [ ] ;
891- textOptions . font [ el ] = { } ;
894+ textOptions . font = toArray ( textOptions . font , { } ) ;
892895 if ( selOptions . textfont . family ) {
893896 textOptions . font [ el ] . family = selOptions . textfont . family ;
894897 }
@@ -898,12 +901,23 @@ function selectPoints(searchInfo, polygon) {
898901 }
899902 }
900903 if ( 'opacity' in selOptions ) {
901- if ( ! textOptions . opacity ) textOptions . opacity = [ ] ;
904+ textOptions . opacity = toArray ( textOptions . opacity , 1 ) ;
902905 textOptions . opacity [ el ] = selOptions . opacity ;
903906 }
904907 }
905908 }
906909
910+ function toArray ( value , dflt ) {
911+ if ( ! Array . isArray ( value ) ) {
912+ var v = value ;
913+ value = Array ( stash . count ) ;
914+ for ( var j = 0 ; j < stash . count ; j ++ ) {
915+ value [ j ] = v !== null ? v : dflt ;
916+ }
917+ }
918+ return value ;
919+ }
920+
907921 scene . selectBatch [ stash . index ] = els ;
908922 scene . unselectBatch [ stash . index ] = unels ;
909923
0 commit comments