File tree 2 files changed +18
-10
lines changed
2 files changed +18
-10
lines changed Original file line number Diff line number Diff line change @@ -62,6 +62,15 @@ export class ColorConverter extends LitElement {
62
62
) ;
63
63
}
64
64
65
+ updateChildren ( ) {
66
+ this . _slottedChildren . forEach ( ( child ) => {
67
+ if ( child instanceof ColorConverterInput ) {
68
+ child . inputValues = this . inputValues ;
69
+ child . color = this . color ;
70
+ }
71
+ } ) ;
72
+ }
73
+
65
74
render ( ) {
66
75
const floatCoordinates = {
67
76
x : this . coordinates . x / this . coordinates . width ,
@@ -75,12 +84,7 @@ export class ColorConverter extends LitElement {
75
84
Math . round ( this . coordinates . x ) ,
76
85
Math . round ( this . coordinates . y ) ,
77
86
] ;
78
- this . _slottedChildren . forEach ( ( child ) => {
79
- if ( child instanceof ColorConverterInput ) {
80
- child . inputValues = this . inputValues ;
81
- child . color = this . color ;
82
- }
83
- } ) ;
87
+ this . updateChildren ( ) ;
84
88
return html `
85
89
${ bootstrap }
86
90
< h5 > Color Converter</ h5 >
@@ -100,7 +104,7 @@ export class ColorConverter extends LitElement {
100
104
</ table >
101
105
< slot
102
106
class ="d-flex flex-column inputs-container "
103
- @slotchange =${ this . render }
107
+ @slotchange =${ this . updateChildren }
104
108
>
105
109
</ slot >
106
110
` ;
Original file line number Diff line number Diff line change @@ -102,8 +102,7 @@ export class ColorPicker extends LitElement {
102
102
) ;
103
103
}
104
104
105
- render ( ) {
106
- this . style . background = "#" + this . color . getHex ( ) ;
105
+ updateChildren ( ) {
107
106
this . _slottedChildren . forEach ( ( child ) => {
108
107
if ( child instanceof ColorSelection ) {
109
108
child . color = this . color ;
@@ -118,10 +117,15 @@ export class ColorPicker extends LitElement {
118
117
child . activeColor = this . interpolationActive ;
119
118
}
120
119
} ) ;
120
+ }
121
+
122
+ render ( ) {
123
+ this . style . background = "#" + this . color . getHex ( ) ;
124
+ this . updateChildren ( ) ;
121
125
return html ` ${ bootstrap }
122
126
< slot
123
127
class ="d-flex flex-row flex-wrap main-container "
124
- @slotchange =${ this . render }
128
+ @slotchange =${ this . updateChildren }
125
129
>
126
130
</ slot > ` ;
127
131
}
You can’t perform that action at this time.
0 commit comments