Skip to content

Commit c5dea6b

Browse files
authored
Merge pull request #25 from arcsi42/master
Change items distance from menu center
2 parents 688e6c9 + 4cdfdea commit c5dea6b

File tree

3 files changed

+13
-7
lines changed

3 files changed

+13
-7
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff 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

src/radial-menu.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff 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) {

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

1718
export interface RadialMenuItemConfig {

0 commit comments

Comments
 (0)