From c6c7e156eeb0b351a0e8549f622522af47fe44a5 Mon Sep 17 00:00:00 2001 From: arcsi42 Date: Sun, 13 Mar 2022 21:14:23 +0100 Subject: [PATCH 1/3] added items_offset config option --- src/radial-menu.ts | 5 +++-- src/types.ts | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/radial-menu.ts b/src/radial-menu.ts index e688958..a790234 100644 --- a/src/radial-menu.ts +++ b/src/radial-menu.ts @@ -41,6 +41,7 @@ export class RadialMenu extends LitElement { action: 'none', }, default_dismiss: true, + items_offset: 0, ...config, }; @@ -81,12 +82,12 @@ export class RadialMenu extends LitElement {
${this._config.items.map((item, index) => { const left = this._config - ? (50 - 35 * Math.cos(-0.5 * Math.PI - 2 * (1 / this._config.items.length) * index * Math.PI)).toFixed( + ? (50 - (35 + (this._config?.items_offset ?? 0)) * Math.cos(-0.5 * Math.PI - 2 * (1 / this._config.items.length) * index * Math.PI)).toFixed( 4, ) + '%' : ''; const top = this._config - ? (50 + 35 * Math.sin(-0.5 * Math.PI - 2 * (1 / this._config.items.length) * index * Math.PI)).toFixed( + ? (50 + (35 + (this._config?.items_offset ?? 0)) * Math.sin(-0.5 * Math.PI - 2 * (1 / this._config.items.length) * index * Math.PI)).toFixed( 4, ) + '%' : ''; diff --git a/src/types.ts b/src/types.ts index bd4efc7..d3368b1 100644 --- a/src/types.ts +++ b/src/types.ts @@ -12,6 +12,7 @@ export interface RadialMenuConfig { hold_action?: ActionConfig; items: RadialMenuItemConfig[]; theme?: string; + items_offset?: number; } export interface RadialMenuItemConfig { From b6077edf8986489b76418633a35259199c2fe0b3 Mon Sep 17 00:00:00 2001 From: arcsi42 Date: Sun, 13 Mar 2022 21:20:25 +0100 Subject: [PATCH 2/3] short description of config option --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fdf071e..30ca7bc 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,8 @@ resources: | `tap_action` | `map` | **Optional** | Action to take on tap. See [action options](#action-options) | `action: toggle-menu` | | `hold_action` | `map` | **Optional** | Action to take on hold. See [action options](#action-options) | `none` | | `double_tap_action` | `map` | **Optional** | Action to take on double tap. See [action options](#action-options) | `action: none` | -| theme | `string` | **Optional** | Card theme | +| `theme` | `string` | **Optional** | Card theme | | +| `items_offset` | `number` | **Optional** | Distance of items from menu center | `0` | ## Item Options From 4cdfdea2dd0b04634dc175f1cf12c32dae080649 Mon Sep 17 00:00:00 2001 From: arcsi42 Date: Sun, 13 Mar 2022 21:38:21 +0100 Subject: [PATCH 3/3] fix prettier errors --- README.md | 2 +- src/radial-menu.ts | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 30ca7bc..f41b26c 100644 --- a/README.md +++ b/README.md @@ -53,7 +53,7 @@ resources: | `hold_action` | `map` | **Optional** | Action to take on hold. See [action options](#action-options) | `none` | | `double_tap_action` | `map` | **Optional** | Action to take on double tap. See [action options](#action-options) | `action: none` | | `theme` | `string` | **Optional** | Card theme | | -| `items_offset` | `number` | **Optional** | Distance of items from menu center | `0` | +| `items_offset` | `number` | **Optional** | Distance of items from menu center | `35` | ## Item Options diff --git a/src/radial-menu.ts b/src/radial-menu.ts index a790234..20869e4 100644 --- a/src/radial-menu.ts +++ b/src/radial-menu.ts @@ -41,7 +41,7 @@ export class RadialMenu extends LitElement { action: 'none', }, default_dismiss: true, - items_offset: 0, + items_offset: 35, ...config, }; @@ -81,15 +81,18 @@ export class RadialMenu extends LitElement {