@@ -13,7 +13,7 @@ var createLine = require('regl-line2d');
13
13
var createError = require ( 'regl-error2d' ) ;
14
14
var cluster = require ( 'point-cluster' ) ;
15
15
var arrayRange = require ( 'array-range' ) ;
16
- var Text = require ( 'gl-text' ) ;
16
+ var Text = require ( '../../../../ gl-text/index ' ) ;
17
17
18
18
var Registry = require ( '../../registry' ) ;
19
19
var Lib = require ( '../../lib' ) ;
@@ -861,17 +861,21 @@ function selectPoints(searchInfo, polygon) {
861
861
862
862
// update texts selection
863
863
if ( hasText ) {
864
- var textOptions = { } ;
864
+ var textOptions = Lib . extendFlat ( { } , scene . textOptions [ stash . index ] ) ;
865
865
if ( els && unels ) {
866
866
if ( els ) {
867
867
applyTextoption ( textOptions , els , scene . selectedOptions [ stash . index ] ) ;
868
868
}
869
869
if ( unels ) {
870
870
applyTextoption ( textOptions , unels , scene . unselectedOptions [ stash . index ] ) ;
871
+ if ( ! scene . unselectedOptions [ stash . index ] . opacity ) {
872
+ applyTextoption ( textOptions , unels , { opacity : 1 } ) ;
873
+ }
871
874
}
872
875
}
873
876
else {
874
- // TODO: reset unselected style properly
877
+ applyTextoption ( textOptions , unels , { opacity : 1 } ) ;
878
+ applyTextoption ( textOptions , unels , scene . textOptions [ stash . index ] ) ;
875
879
}
876
880
877
881
scene . glText [ stash . index ] . update ( textOptions ) ;
@@ -883,12 +887,11 @@ function selectPoints(searchInfo, polygon) {
883
887
var el = els [ i ] ;
884
888
if ( selOptions . textfont ) {
885
889
if ( selOptions . textfont . color ) {
886
- if ( ! textOptions . color ) textOptions . color = [ ] ;
890
+ textOptions . color = toArray ( textOptions . color ) ;
887
891
textOptions . color [ el ] = selOptions . textfont . color ;
888
892
}
889
893
if ( selOptions . textfont . family || selOptions . textfont . size ) {
890
- if ( ! textOptions . font ) textOptions . font = [ ] ;
891
- textOptions . font [ el ] = { } ;
894
+ textOptions . font = toArray ( textOptions . font , { } ) ;
892
895
if ( selOptions . textfont . family ) {
893
896
textOptions . font [ el ] . family = selOptions . textfont . family ;
894
897
}
@@ -898,12 +901,23 @@ function selectPoints(searchInfo, polygon) {
898
901
}
899
902
}
900
903
if ( 'opacity' in selOptions ) {
901
- if ( ! textOptions . opacity ) textOptions . opacity = [ ] ;
904
+ textOptions . opacity = toArray ( textOptions . opacity , 1 ) ;
902
905
textOptions . opacity [ el ] = selOptions . opacity ;
903
906
}
904
907
}
905
908
}
906
909
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
+
907
921
scene . selectBatch [ stash . index ] = els ;
908
922
scene . unselectBatch [ stash . index ] = unels ;
909
923
0 commit comments