File tree 1 file changed +44
-4
lines changed
packages/component-webaudio/src
1 file changed +44
-4
lines changed Original file line number Diff line number Diff line change @@ -65,14 +65,54 @@ class WAKnob extends HTMLElement {
65
65
66
66
private render ( ) {
67
67
if ( ! this . shadowRoot ) return ;
68
+
69
+ // Calculate rotation angle based on value
70
+ const range = this . _max - this . _min ;
71
+ const normalizedValue = ( this . _value - this . _min ) / range ;
72
+ const angle = normalizedValue * 270 - 135 ; // -135 to +135 degrees range
73
+
68
74
this . shadowRoot . innerHTML = `
69
- <div class='webaudio-knob-body' tabindex='1' touch-action='none'>
70
- <div class='webaudioctrl-tooltip'></div>
71
- <div part="label" class="webaudioctrl-label">
75
+ <style>
76
+ .knob-body {
77
+ width: 60px;
78
+ height: 60px;
79
+ display: flex;
80
+ flex-direction: column;
81
+ align-items: center;
82
+ }
83
+ .knob-svg {
84
+ width: 100%;
85
+ height: 100%;
86
+ }
87
+ .knob-base {
88
+ fill: #444;
89
+ stroke: #666;
90
+ stroke-width: 2;
91
+ }
92
+ .knob-indicator {
93
+ stroke: #fff;
94
+ stroke-width: 2;
95
+ stroke-linecap: round;
96
+ }
97
+ .ctrl-label {
98
+ margin-top: 5px;
99
+ text-align: center;
100
+ }
101
+ </style>
102
+ <div class='knob-body'>
103
+ <svg class="knob-svg" viewBox="0 0 60 60">
104
+ <circle class="knob-base" cx="30" cy="30" r="25"/>
105
+ <line class="knob-indicator"
106
+ x1="30"
107
+ y1="30"
108
+ x2="30"
109
+ y2="10"
110
+ transform="rotate(${ angle } , 30, 30)"/>
111
+ </svg>
112
+ <div part="label" class="ctrl-label">
72
113
<slot></slot>
73
114
</div>
74
115
</div>
75
- <div>Value: ${ this . _value } (Min: ${ this . _min } , Max: ${ this . _max } )</div>
76
116
` ;
77
117
}
78
118
You can’t perform that action at this time.
0 commit comments