Radial Menu
by James Butler
HTML
<div class="wrap">
<div class="parent"></div>
<div class="circle">
<img src="http://placekitten.com/g/300/300" />
</div>
<div class="circle">
<img src="http://placekitten.com/g/200/300" />
</div>
<div class="circle">
<img src="http://cdn.flaticon.com/png/256/56729.png" />
</div>
<div class="circle">
<img src="http://cdn.flaticon.com/png/256/54976.png" />
</div>
<div class="circle">Just Text</div>
<div class="circle">
<img src="http://cdn.flaticon.com/png/256/56582.png" />
</div>
</div>
CSS
html,body{background:darkgray;}
.wrap {
height:300px;
width:300px;
position:relative;
transform-origin: center center;
transition:all 0.8s;
}
.circle {
transition:all 0.8s;
position:absolute;
height:5px;
width:5px;
text-align: center;
line-height: 15px;
top: calc(50% - 2px);
left: calc(50% - 2px);
border-radius: 50%;
overflow:hidden;
}
.parent{
transition:all 0.8s;
position:absolute;
background:gray;
height:50px;
width:50px;
text-align: center;
line-height: 25px;
top: calc(50% - 25px);
left: calc(50% - 25px);
border-radius: 50%;
z-index:8;
box-shadow: inset 2px 2px 10px black, inset 0 0 15px black, 0 0 15px black;
}
.parent:before,.parent:after{
content:"";
position:absolute;
transition:all 0.8s;
height:5px;
width:25px;
top:22px;
left:12px;
background:black;
opacity:1;
}
.parent:before{
top:15px;
box-shadow: 0 14px 0 black;
}
.parent:hover:before,.parent:hover:after{
transform:translate(0,20px);
color:gray;
opacity:0;
box-shadow: 0 14px 0 none;
}
.wrap:hover .parent,.wrap:hover .parent:before,.wrap:hover .parent:after{
background:darkgray;
}
.wrap:hover .parent:before{
box-shadow:none;
}
.wrap:hover .circle {
height:50px;
width:50px;
line-height: 25px;
top: calc(50% - 25px);
left: calc(50% - 25px);
box-shadow: inset 2px 2px 10px black, inset 0 0 15px black, 0 0 15px black;
}
.circle img {
position:absolute;
height:100%;
width:100%;
left:0;
top:0;
}
.circle:before {
border-radius:50%;
transition:all 0.8s;
content:"";
position:absolute;
height:100%;
width:100%;
top:0;
left:0;
z-index:8;
}
.circle:after {
transition:all 0.8s;
border-radius:50%;
content:"";
position:absolute;
height:200%;
width:200%;
top:50%;
left:200%;
z-index:8;
background: -moz-linear-gradient(left,...
JavaScript
+ function() {
var to;
$(".wrap").on('mouseenter', function() {
var circles = $(this).find(".circle");
var degree = (2 * Math.PI) / circles.length; //calc delta angle
var transforms = [];
// Calculate the position for each circle
circles.each(function(index) {
var x = 100 * Math.cos(-0.5 * Math.PI + degree * (-1 * index - 0.5));
var y = 100 * Math.sin(-0.5 * Math.PI + degree * (-1 * index - 0.5));
transforms.push('translate(' + x + 'px,' + y + 'px)');
});
// Function to moves all the circles
// We'll pop a circle each time and than call this function recursively
function moveCircles() {
var transform = transforms.shift();
circles.css('transform', transform);
circles.splice(0, 1);
if (circles.length) to = setTimeout(moveCircles, 400);
}
moveCircles();
});
$(".wrap").on('mouseleave', function() {
var circles = $(this).children().css('transform', '');
clearTimeout(to);
});
}();