interface MenuConfig {
angle?:number; // define menu radian eg:Math.PI / 6
callback?:Function; // called when menu created
}
interface Menu extends MenuConfig {
name:String; // menu name
caption:String; // menu caption
html?:String; // menu html content
icon?:String; // menu icon
menuList?:MenuList; // subMenu define
}
interface MenuList extends MenuConfig {
items:Menu[]; // menu list
radiusStep?:number; // whitespace of two arc
offsetRadius?:number; // distance of two arc
}
interface AnnularMenuOption {
menuList:MenuList;
startAngle?:number;
centerSize?:number;
collapsible?:boolean;
draggable?:boolean;
}
interface Point {
x:number;
y:number;
}
interface EventListeners {
click:Function,
mouseover:Function
menuClick:Function[],
menuHover:Function[]
}
//second level menu
var menus_1 = [];
for(var i = 0;i < 4;i++){
menus_1.push({
name: 'M1_' + i,
caption: 'M1_' + i,
icon: './image/icon.png',
angle:Math.PI / 4,
menuList:{
radiusStep:5,
items:[]
}
});
}
// first level menu
var menus_0 = [];
for(i = 0;i < 4;i++){
menus_1.push({
name: 'M0_' + i,
caption: 'M0_' + i,
icon: './image/icon.png',
menuList:{
radiusStep:8,
items:menus_1
}
});
}
var contextMenu = new HERE.UI.AnnularMenu({
menuList:{
items:menus_0
}
});
var centerX = document.body.clientWidth / 2,
centerY = document.body.clientHeight / 2;
var element = contextMenu.render({
x:centerX,
y:centerY
});
var container = document.querySelector('.menu-container');
container.appendChild(element);
- menuClick
- menuHover
- click
- mouseover
contextMenu.addEventListener('menuClick', function (e,menu) {
});
- render(position?:Point):SVGElement
- scale(point?:Point)
- position(point?:Point)
- toggleCollapse(collapse?:boolean)
- toggleVisible(visible?:boolean)
- addEventListener(type:String, handler:Function)
- removeEventListener(type:String, handler:Function)