circular menu jquery plugin
just a circular menu jquery plugin
by melc
HTML
<div class="menu"> <a href=#></a>
<ul>
<li><a href=#>1</a>
</li>
<li>2</li>
<li>3</li>
<li>4</li>
<li>5</li>
<li>6</li>
<li>7</li>
</ul>
</div>
<!-- <div class="debug-point" style="display:block;width:1px;height:1px;background-color:blue"></div> -->
CSS
.menu {
margin-left:100px;
margin-top:100px;
background-color:firebrick;
}
.menu li {
background-color:red;
}
JavaScript
/*
http://en.wikipedia.org/wiki/Circle#Equations
d*Pi/180 = r
x = OriginX + r*cosT
y = OriginY + r*sinT
0<=T<=2Pi
*/
/** the actual object - start **/
function RoundMenu($object, menusize, optionsize, distance, span, offset, ismenuround, isoptionsround, animate, onShow, onHide) {
var $ = jQuery;
return {
menuSize: menusize,
optionSize: optionsize,
isMenuRound: ismenuround,
isOptionsRound: isoptionsround,
radius: parseInt(distance),
offsetAngle: offset,
angle: 0,
menuOriginX: 0,
menuOriginY: 0,
optionsCords: [],
optionsVisible: false,
init: function () {
this.calculateMenuOrigin();
this.calculateAngleForOptions();
this.prepareMenuCss();
this.prepareMenuOptionsCss();
this.storeCoords();
this.addListener();
},
calculateMenuOrigin: function () {
this.menuOriginX = this.calculateOriginX();
this.menuOriginY = this.calculateOriginY();
},
calculateAngleForOptions: function () {
var numberOfOptions = $object.find('> ul > li').length;
if (numberOfOptions > 1) {
this.angle = (span / (numberOfOptions - 1));
} else {
this.angle = (span / numberOfOptions);
}
},
prepareMenuCss: function () {
/* prepare menu - start */
$object.css({
"width": this.menuSize,
"height": this.menuSize
});
$object.find('a').css({
"display": "block",
"width": "100%",
"height": "100%",
"-webkit-tap-highlight-color": "transparent"
});
//for IE when link clicked....
/*$object.find('a').focus(function(){$(this).css({
"background-color": "transparent"
...