Search results

Radial Menu in JavaScript (ES5) SpeedDial control

06 Jun 2023 / 2 minutes to read

The JavaScript(ES5) Speed Dial action items can be displayed in a circular patter like a radial menu by setting mode property. You can customize the direction, startAngle, endAngle and offset by setting radialSettings property.

Radial menu direction

You can open the action items in either clockwise or anticlockwise by setting direction property. The default value is Auto where the action items are displayed based on the position property of the Speed Dial.

Copied to clipboard
// Initialize action items
var items = [
    { iconCss: 'e-icons e-cut' },
    { iconCss: 'e-icons e-copy' },
    { iconCss: 'e-icons e-paste' }
];

// Initialize the SpeedDial control in anticlockwise direction
var radialSettings = { direction: 'AntiClockwise' };

// Initialize the SpeedDial control
var speedDial = new ej.buttons.SpeedDial({
    items: items,
    openIconCss: 'e-icons e-edit',
    target: '#targetElement',
    mode: 'Radial',
    radialSettings: radialSettings
});

// Render initialized SpeedDial
speedDial.appendTo('#speedDial');

Radial menu start and end angle

You can modify the start and end angle of action items by setting startAngle and endAngle properties. If the angle is not defined, the action items are displayed based on the position property of the Speed Dial.

Copied to clipboard
// Initialize action items
var items = [
    { iconCss: 'e-icons e-cut' },
    { iconCss: 'e-icons e-copy' },
    { iconCss: 'e-icons e-paste' },
];

// Initialize radial direction with start and end angles
var radialSettings = { direction: 'AntiClockwise', startAngle: 180, endAngle: 360 };

// Initialize the SpeedDial control
var speedDial = new ej.buttons.SpeedDial({
    items: items,
    openIconCss: 'e-icons e-edit',
    target: '#targetElement',
    mode: 'Radial',
    position: 'MiddleCenter',
    radialSettings: radialSettings
});

// Render initialized SpeedDial
speedDial.appendTo('#speedDial');

Offset

You can modify the offset distance between action items and Speed Dial button using offset property.

Copied to clipboard
// Initialize action items
var items = [
    { iconCss: 'e-icons e-cut' },
    { iconCss: 'e-icons e-copy' },
    { iconCss: 'e-icons e-paste' }
];

// Initialize radial direction with offset
var radialSettings = { offset: '80px' };

// Initialize the SpeedDial control
var speedDial = new ej.buttons.SpeedDial({
    items: items,
    openIconCss: 'e-icons e-edit',
    target: '#targetElement',
    mode: 'Radial',
    radialSettings: radialSettings
});

// Render initialized SpeedDial
speedDial.appendTo('#speedDial');

Below example demonstrates the radial menu settings of the Speed Dial.

Source
Preview
index.js
index.html
styles.css
Copied to clipboard
ej.base.enableRipple(true);

// Initialize action items
var items = [
    { iconCss:'e-icons e-cut'},
    { iconCss:'e-icons e-copy'},
    { iconCss:'e-icons e-paste'},
    { iconCss:'e-icons e-edit'},
    { iconCss:'e-icons e-save'}
];

// Initialize radial direction
var radialSettings = { offset: '80px', direction: 'AntiClockwise', startAngle: 90, endAngle: 270 };

// Initialize the SpeedDial component
var speedDial = new ej.buttons.SpeedDial({
    items: items,
    openIconCss:'e-icons e-edit',
    target: '#targetElement',
    mode: 'Radial',
    position: 'MiddleRight',
    radialSettings: radialSettings
});

// Render initialized SpeedDial
speedDial.appendTo('#speeddial');
Copied to clipboard
<!DOCTYPE html><html lang="en"><head>
            
    <title>EJ2 SpeedDial</title>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Typescript UI Controls">
    <meta name="author" content="Syncfusion">
    <!-- Add the SpeedDial component styles. -->
    <link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-base/styles/material.css" rel="stylesheet">
    <link href="//cdn.syncfusion.com/ej2/21.2.3/ej2-buttons/styles/material.css" rel="stylesheet">
    <link href="styles.css" rel="stylesheet">
    
    
<script src="https://cdn.syncfusion.com/ej2/21.2.3/dist/ej2.min.js" type="text/javascript"></script>
</head>

<body>
    
    <div id="container">
        <!-- Elements to render the SpeedDial component. -->
        <div id="targetElement" style="position:relative;min-height:350px;border:1px solid;"></div>
        <button id="speeddial"></button>
    </div>


<script>
var ele = document.getElementById('container');
if(ele) {
    ele.style.visibility = "visible";
 }   
        </script>
<script src="index.js" type="text/javascript"></script>
</body></html>
Copied to clipboard
#container {
    visibility: hidden;
}

#loader {
  color: #008cff;
  height: 40px;
  left: 45%;
  position: absolute;
  top: 45%;
  width: 30%;
}