File tree Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Expand file tree Collapse file tree 1 file changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -80,7 +80,15 @@ export class PotentiometerElement extends LitElement {
80
80
stroke-width =".30 "
81
81
/>
82
82
< rect x ="5.4 " y =".70 " width ="9.1 " height ="1.9 " fill ="#ccdae3 " stroke-width =".15 " />
83
- < ellipse cx ="9.91 " cy ="8.18 " rx ="7.27 " ry ="7.43 " fill ="#e4e8eb " stroke-width =".15 " />
83
+ < ellipse
84
+ id ="knob "
85
+ cx ="9.91 "
86
+ cy ="8.18 "
87
+ rx ="7.27 "
88
+ ry ="7.43 "
89
+ fill ="#e4e8eb "
90
+ stroke-width =".15 "
91
+ />
84
92
< rect
85
93
x ="6.6 "
86
94
y ="17 "
@@ -134,12 +142,14 @@ export class PotentiometerElement extends LitElement {
134
142
event . stopPropagation ( ) ;
135
143
event . preventDefault ( ) ;
136
144
137
- const potentiometerRect = this . getBoundingClientRect ( ) ;
145
+ const potentiometerRect = this . shadowRoot ?. querySelector ( '#knob' ) ?. getBoundingClientRect ( ) ;
138
146
139
- this . center = {
140
- x : window . scrollX + potentiometerRect . left + potentiometerRect . width / 2 ,
141
- y : window . scrollY + potentiometerRect . top + potentiometerRect . height / 2 ,
142
- } ;
147
+ if ( potentiometerRect ) {
148
+ this . center = {
149
+ x : window . scrollX + potentiometerRect . left + potentiometerRect . width / 2 ,
150
+ y : window . scrollY + potentiometerRect . top + potentiometerRect . height / 2 ,
151
+ } ;
152
+ }
143
153
}
144
154
145
155
private rotateHandler ( event : MouseEvent | TouchEvent ) {
You can’t perform that action at this time.
0 commit comments