cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

Quick-add: + add another resource

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

            
              %nav
	%ul
		- 8.times do
			%li
				%a{:href => '#'} menu item
	.hotspot.l
	.hotspot.r
            
          
!
            
              $hotspot-d: 1.5em;

html {
	overflow-x: hidden;
	/* background lifted from http://lea.verou.me/css3patterns/#carbon-fibre */
	background:
		radial-gradient(#000 15%, transparent 16%),
		radial-gradient(#000 15%, transparent 16%) 8px 8px,
		radial-gradient(rgba(#000,.1) 15%, transparent 20%) 0 1px,
		radial-gradient(rgba(#000,.1) 15%, transparent 20%) 8px 9px #282828;
	background-size:16px 16px;
	color: #d1d7e3;
	font: 1em/2.5 century gothic, verdana, sans-serif;
	text-align: center;
}

body { margin: 0; }

nav {
	position: relative;
	margin: 0 auto;
	width: 20em;
	cursor: pointer;
}

.dragged {
	user-select: none;
}

ul {
	margin: 0;
	padding: 0;
	list-style: none;
}

li {
	overflow: hidden;
	transform-origin: 50% 0;
	will-change: transform;
	
	&:last-child { border-radius: 0 0 .5em .5em; }
	
	&:not(:first-child) {
		border-top: solid 1px #1c1b20;
	}
	&:not(:last-child) {
		border-bottom: solid 1px #484d53;
	}
}

a {
	display: block;
	position: relative;
	margin-left: calc(10em - 50vw);
	width: 100vw;
	opacity: .999; /* stacking context hack */
	background: rgba(#3a3f45, .65);
	color: inherit;
	text-decoration: none;
	will-change: color, transform;
	transition: color .7s;
	
	&:before {
		position: absolute;
		z-index: -1;
		top: 0; right: 0; bottom: 0; left: 0;
		opacity: .001;
		background: linear-gradient(#dee271, #b8b42c);
		will-change: opacity;
		transition: opacity .7s;
		content: '';
	}
	
	&:hover, &:focus {
		color: black;
		
		&:before { opacity: .999; }
	}
}

.hotspot {
	&, &:before, &:after {
		box-sizing: border-box;
		position: absolute;
		border-radius: 50%;
	}
	
	bottom: -.5*$hotspot-d;
	border: solid .375*$hotspot-d transparent;
	width: $hotspot-d; height: $hotspot-d;
	opacity: .1;
	background: #f72a63;
	background-clip: content-box;
	will-change: opacity;
	
	&:first-of-type { left: -.5*$hotspot-d; }
	&:last-of-type { right: -.5*$hotspot-d; }
	
	&:before, &:after {
		top: 50%; left: 50%;
		margin: -.125*$hotspot-d;
		border: solid .125*$hotspot-d #f72a63;
		width: .25*$hotspot-d; height: .25*$hotspot-d;
		will-change: all;
		content: '';
	}
	
	&:hover {
		opacity: .99;
		
		&:before, &:after {
			animation: p 1.3s ease-in-out infinite;
		}
		&:after { animation-delay: -.65s; }
	}
}

@keyframes p {
	to {
		margin: -$hotspot-d;
		border: solid .25*$hotspot-d #f72a63;
		width: 2*$hotspot-d; height: 2*$hotspot-d;
		opacity: .1;
		-webkit-filter: blur(2px);
		filter: blur(2px);
	}
}
            
          
!
            
              /* because IE up to and including 11 */
Math.sign = Math.sign || function(x) {
  x = +x; // convert to a number
  if(x === 0 || isNaN(x)) {
    return x;
  }
  return x > 0 ? 1 : -1;
};

/* because me lazy */
Object.getOwnPropertyNames(Math).map(function(p) {
  window[p] = Math[p];
});

var nav = document.querySelector('nav'), 
		r, side = null, dragging = false, 
		sgn = 0, a, b, max_a, 
		items = document.querySelectorAll('li'), 
		links = document.querySelectorAll('a'), 
		n = items.length, 
		style = document.createElement('style'), 
		t = 0, r_id = null;

var size = function() {
	r = nav.getBoundingClientRect();
};

var distortMenu = function(xo) {
	var tx = 0, x1, x2, y1, y2, beta;
	
	for(var i = 0; i < n; i++) {
		x1 = xo + sgn*a*cos(asin(i/n));
		x2 = xo + sgn*a*cos(asin((i + 1)/n));
		y1 = r.top + i*b/n;
		y2 = r.top + (i + 1)*b/n;
		beta = sign(a)*sgn*(atan(abs((y2 - y1)/(x2 - x1))) - .5*PI);
		
		items[i].style.transform = 
			'translate(' + tx + 'px)' + 
			'skewX(' + beta + 'rad)';
		links[i].style.transform = 
			'skewX(' + -beta + 'rad)';
		
		tx = x2 - (r.left + side*r.width);
	}
	
	style.textContent = 
		'.hotspot{transform:translate(' + tx + 'px)}'
};

var oscillate = function() {
	var curr_xo;
	
	a = max_a*cos(t*2*PI/60);
	curr_xo = r.left + side*r.width - sgn*a;
	
	distortMenu(curr_xo);
	
	t++;
	max_a *= .99;
	
	if(max_a < 1) {
		cancelAnimationFrame(r_id);
		r_id = null;
		t = 0;
		
		for(var i = 0; i < n; i++) {
			items[i].style.transform = 
			links[i].style.transform = 'none';
		}
		
		style.textContent = '';
		
		return;
	}
	
	r_id = requestAnimationFrame(oscillate);
};


document.body.appendChild(style);
size();


addEventListener('resize', size, false);

addEventListener('mousedown', function(e) {
	if(e.target.classList.contains('hotspot')) {
		dragging = true;
		nav.classList.add('dragged');
		side = e.target.classList.contains('l')?0:1;
		
		if(r_id) {
			cancelAnimationFrame(r_id);
			r_id = null;
			t = 0;
		}
	}
}, false);

addEventListener('mousemove', function(e) {
	var x, y, dx1, dx2;
	
	if(dragging) {
		x = e.clientX;
		y = e.clientY;
		
		dx1 = r.left + r.width - x;
		dx2 = r.left - x;
		
		a = side ? abs(dx1) : abs(dx2);
		b = r.height;
		
		sgn = sign(side?dx1:dx2);
		
		distortMenu(x);
	}
}, false);

addEventListener('mouseup', function(e) {
	if(dragging) {
		dragging = false;
		nav.classList.remove('dragged');
		max_a = a;
		oscillate();
	}
}, false);
            
          
!
999px
Loading ..................

Console