function ChainedLightening(parentNode,data) {
// create the dom element for menu
var nav = $('<nav class="chainedlightening"></nav>');
var nextPane = function(){
nav.find('>ul').each(function(){
var z = parseInt($(this).attr('data-z'))-500;
var o = 1/Math.abs(z)*50;
var pe = 'none';
if(z == 0 ){
o = 1;
pe = 'auto';
}
$(this).attr('data-z',z).css('transform','translateZ(' + z + 'px)').css('opacity',o).css('pointer-events',pe);
});
}
var mapPosition = function(x,y,r,d){
console.log("ROTATION",r);
x += d * Math.sin(r * Math.PI / 180);
y -= d * Math.cos(r * Math.PI / 180);
return { x: x, y: y };
}
for(var i=0;i<data.length;i++){
var z = parseInt(i*500);
var menu = $('<ul data-z="' + z + '" style="transform:translateZ(' + z + 'px);"></ul>');
var deg = 0;
var degInt = 360 / data[i].length;
for(var ii=0;ii<data[i].length;ii++){
var position = mapPosition(0,0,deg,180);
if(data[i].length == 1){
position = { x: 0, y: 0 }
}
console.log(position);
var item = $('<li style="transform:translateX(' + position.x + 'px) translateY(' + position.y + 'px);"><div><span>' + data[i][ii].label + '</span></div></li>');
deg+=degInt;
if(i == 0){
item.click(function(){
nextPane();
});
} else {
item.click(function(){
nextPane();
});
}
menu.append(item);
}
nav.append(menu);
}
parentNode.append(nav);
}
// first 2 levels are loaded when instance is created
new ChainedLightening($('body'),Array(
Array(
{
label: "Brain",
hyperlink: "lookup:Brain"
}
),
Array(
{
label: "Reactive Brain",
hyperlink:...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.