File tree Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Expand file tree Collapse file tree 3 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -52,7 +52,8 @@ resources:
5252| `tap_action` | `map` | **Optional** | Action to take on tap. See [action options](#action-options) | `action: toggle-menu` |
5353| `hold_action` | `map` | **Optional** | Action to take on hold. See [action options](#action-options) | `none` |
5454| `double_tap_action` | `map` | **Optional** | Action to take on double tap. See [action options](#action-options) | `action: none` |
55- | theme | `string` | **Optional** | Card theme |
55+ | `theme` | `string` | **Optional** | Card theme | |
56+ | `items_offset` | `number` | **Optional** | Distance of items from menu center | `35` |
5657
5758# # Item Options
5859
Original file line number Diff line number Diff line change @@ -41,6 +41,7 @@ export class RadialMenu extends LitElement {
4141 action : 'none' ,
4242 } ,
4343 default_dismiss : true ,
44+ items_offset : 35 ,
4445 ...config ,
4546 } ;
4647
@@ -80,15 +81,18 @@ export class RadialMenu extends LitElement {
8081 <nav class= "circular-menu" >
8182 <div class= "circle" >
8283 ${ this . _config . items . map ( ( item , index ) => {
84+ const _items_offset = this . _config ?. items_offset ?? 35 ;
8385 const left = this . _config
84- ? ( 50 - 35 * Math . cos ( - 0.5 * Math . PI - 2 * ( 1 / this . _config . items . length ) * index * Math . PI ) ) . toFixed (
85- 4 ,
86- ) + '%'
86+ ? (
87+ 50 -
88+ _items_offset * Math . cos ( - 0.5 * Math . PI - 2 * ( 1 / this . _config . items . length ) * index * Math . PI )
89+ ) . toFixed ( 4 ) + '%'
8790 : '' ;
8891 const top = this . _config
89- ? ( 50 + 35 * Math . sin ( - 0.5 * Math . PI - 2 * ( 1 / this . _config . items . length ) * index * Math . PI ) ) . toFixed (
90- 4 ,
91- ) + '%'
92+ ? (
93+ 50 +
94+ _items_offset * Math . sin ( - 0.5 * Math . PI - 2 * ( 1 / this . _config . items . length ) * index * Math . PI )
95+ ) . toFixed ( 4 ) + '%'
9296 : '' ;
9397
9498 if ( item . card && item . element ) {
Original file line number Diff line number Diff line change @@ -12,6 +12,7 @@ export interface RadialMenuConfig {
1212 hold_action ?: ActionConfig ;
1313 items : RadialMenuItemConfig [ ] ;
1414 theme ?: string ;
15+ items_offset ?: number ;
1516}
1617
1718export interface RadialMenuItemConfig {
You can’t perform that action at this time.
0 commit comments