mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-17 15:06:02 +01:00
refactor(web/menu): always draw full radial menu circle
This commit is contained in:
@@ -7,7 +7,6 @@ export const debugRadial = () => {
|
||||
action: 'openRadialMenu',
|
||||
data: {
|
||||
items: [
|
||||
// TODO: Fix wheel being broken when there's only one item
|
||||
{ icon: 'palette', label: 'Paint' },
|
||||
{ icon: 'warehouse', label: 'Garage' },
|
||||
{ icon: 'palette', label: 'Quite long text' },
|
||||
|
||||
@@ -79,13 +79,12 @@ const RadialMenu: React.FC = () => {
|
||||
<ScaleFade visible={visible}>
|
||||
<svg width="350px" height="350px" transform="rotate(90)">
|
||||
{/*Fixed issues with background circle extending the circle when there's less than 3 items*/}
|
||||
{menu.items.length >= 3 && (
|
||||
<g transform="translate(175, 175)">
|
||||
<circle r={175} className={classes.backgroundCircle} />
|
||||
</g>
|
||||
)}
|
||||
<g transform="translate(175, 175)">
|
||||
<circle r={175} className={classes.backgroundCircle} />
|
||||
</g>
|
||||
{menu.items.map((item, index) => {
|
||||
const pieAngle = 360 / menu.items.length;
|
||||
// Always draw full circle to avoid elipse circles with 2 or less items
|
||||
const pieAngle = 360 / (menu.items.length < 3 ? 3 : menu.items.length);
|
||||
const angle = degToRad(pieAngle / 2 + 90);
|
||||
const radius = 175 * 0.65;
|
||||
const iconX = 175 + Math.sin(angle) * radius;
|
||||
|
||||
Reference in New Issue
Block a user