File tree Expand file tree Collapse file tree
src/components/rotary-knob Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -139,8 +139,15 @@ export class ContinuousRotaryKnob {
139139 return this . dom_ ;
140140 }
141141
142+ /**
143+ * Sync the knob display to match an externally-set angle.
144+ * Does NOT trigger callback - this is for updating the visual
145+ * to match state that was set elsewhere.
146+ */
142147 sync ( newAngle : number ) : void {
143- this . setAngle_ ( newAngle ) ;
148+ this . angle = newAngle ;
149+ this . totalRotations = Math . floor ( this . angle / 360 ) ;
150+ this . updateDisplay ( ) ;
144151 }
145152
146153 static create (
Original file line number Diff line number Diff line change @@ -148,8 +148,22 @@ export class RotaryKnob {
148148 return this . dom_ ;
149149 }
150150
151+ /**
152+ * Sync the knob display to match an externally-set value.
153+ * Does NOT trigger callback or sounds - this is for updating the visual
154+ * to match state that was set elsewhere.
155+ */
151156 sync ( newValue : number ) : void {
152- this . setValue_ ( newValue ) ;
157+ // Clamp to valid range
158+ newValue = Math . max ( this . min , Math . min ( this . max , newValue ) ) ;
159+
160+ // Round to 3 decimal places to avoid floating point issues
161+ newValue = Number ( newValue . toFixed ( 3 ) ) ;
162+
163+ // Update internal value and display without callback
164+ this . value = newValue ;
165+ this . updateAngleFromValue_ ( ) ;
166+ this . updateDisplay ( ) ;
153167 }
154168
155169 static create (
You can’t perform that action at this time.
0 commit comments