Pen Settings

HTML

CSS

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.

+ add another resource

JavaScript

Babel includes JSX processing.

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.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                - var amin = 90, amax = 157, aval = 120;

form
	section
		label(for='sa') start angle
		span.swrap(style=`--min:${-amax};--max:${-amin};--val:${-aval}`)
			input#sa(type='range' min=-amax max=-amin value=-aval)
			output(for='sa') #{-aval}
	section
		label(for='ea') end angle
		span.swrap(style=`--min:${amin};--max:${amax};--val:${aval}`)
			input#ea(type='range' min=amin max=amax value=aval)
			output(for='ea') #{aval}

#result: p Click anywhere under the top form.
              
            
!

CSS

              
                $demo-lh: 1.25;
$demo-dark: #262626;
$demo-light: invert($demo-dark);
$demo-ll: #555;
$demo-hl: #f90;
$ctrl-pad: .5em;
$ctrl-wmax: 32em;

$lbl-w: 5.25em;

$thumb-d: 1.25em;
$thumb-r: .5*$thumb-d;

$track-h: 6px;
$track-r: .5*$track-h;
$track-m: calc((100% - #{$thumb-d}));
$track-s: calc(#{$track-m}/var(--range));
$track-x: calc(#{-$track-r} - .5*#{$track-m}/var(--range));

$t: .3s;

@mixin track {
	border: none;
	width: 100%; height: $track-h;
	border-radius: $track-r;
	background: $demo-ll;
	background: 
		radial-gradient(circle at calc(var(--pos) + #{$thumb-r}) 50%, 
				transparent $thumb-r, $demo-ll 0);
}

@mixin thumb {
	box-sizing: border-box;
  border: solid .25*$thumb-d transparent;
	width: $thumb-d; height: $thumb-d;
	border-radius: 50%;
	background: $demo-ll content-box;
	transition: $t;
	transition-property: border-width, background-color
}

@mixin thumb-focus {
	border-width: 0;
	background: $demo-hl
}

* {
	margin: 0;
	font: inherit;
	vector-effect: non-scaling-stroke
}

html { font: 1.25em/ #{$demo-lh} trebuchet ms, sans-serif }

body {
	--fs: 1.125em;
	--stop-ini: 62%;
	--stop-fin: 38%;
	display: flex;
	flex-direction: column;
	overflow: hidden;
	min-height: 10em; height: 100vh;
	text-align: center
}

form {
	display: flex;
	align-self: center;
	align-items: center;
	justify-content: space-around;
	border: solid 0 $demo-dark;
	border-width: 0 calc(50vw - .5*#{$ctrl-wmax});
	padding: $ctrl-pad;
	width: 100vw;
	max-width: $ctrl-wmax;
	background: $demo-dark;
	color: $demo-light;
	
	@media (max-width: 600px) {
		flex-direction: column;
		
		.swrap { width: calc(100% - #{2*$ctrl-pad}) }
	}
}

section {
	flex: 1;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	border: none;
	padding: .25em 0 1.25em;
	max-width: $ctrl-wmax;
}

label {
	padding-right: .5em;
	width: $lbl-w;
	text-align: right;
	
	&:after { content: ':' }
}

.swrap {
	--range: calc(var(--max) - var(--min));
	--pos: calc((var(--val) - var(--min))*(100% - #{$thumb-d})/var(--range));
	position: relative;
	width: calc(100% - #{2*$ctrl-pad + $lbl-w});
}

[type='range'] {
	&::-webkit-slider-runnable-track, 
	&::-webkit-slider-thumb, & {
		-webkit-appearance: none
	}
	
	width: 100%; height: 1.5*$thumb-d;
	background: transparent;
	cursor: pointer;
	
	&::-webkit-slider-runnable-track {
		@include track
	}
	
	&::-moz-range-track {
		@include track
	}
	
	&::-ms-track {
		@include track;
		background: $demo-ll;
		color: transparent
	}
	
	&::-ms-fill-lower {
		display: none
	}
	
	&::-webkit-slider-thumb {
		margin-top: calc(#{$track-r} - #{$thumb-r});
		@include thumb
	}
	
	&::-moz-range-thumb {
		@include thumb
	}
	
	&::-ms-thumb {
		margin-top: 0;
		@include thumb;
		border-color: $demo-dark
	}

	&:focus {
		outline: none;
		
		&::-webkit-slider-thumb {
			@include thumb-focus
		}

		&::-moz-range-thumb {
			@include thumb-focus
		}

		&::-ms-thumb {
			@include thumb-focus
		}
		
		+ output { --f: .99 }
	}
	
	+ output {
		--f: .01;
		position: absolute;
		top: 100%; left: calc(#{$thumb-r} + var(--pos));
		padding: 0 .375em;
		border-radius: 5px;
		transform-origin: 50% 0;
		transform: translate(-50%) scale(var(--f));
		opacity: var(--f);
		background: $demo-hl;
		transition: opacity $t;
	}
	
	@supports not (clip-path: circle(5px)) {
		+ output { display: none }
	}
}

[id='result'] {
	font-weight: 700;
}

article {
	position: relative;
	margin-top: 3em;
	min-height: 3.5em;
	background: linear-gradient(90deg, 
		#ff9800 var(--stop, var(--stop-ini)), 
		#3c3c3c 0);
}

h3 {
	position: absolute;
	bottom: 100%; left: .5em;
	font-size: 1.25em;
}

p { line-height: 3 }
              
            
!

JS

              
                const _S = document.querySelector('span'), 
			_ART = [], 
			NF = 50, 
			_RES = document.getElementById('result'), 
			END_NAMES = ['s', 'e'], 
			N_ENDS = END_NAMES.length,
			VARS = {}, 
			S = getComputedStyle(_RES), 
			INI = +S.getPropertyValue('--stop-ini').replace('%', ''), 
			FIN = +S.getPropertyValue('--stop-fin').replace('%', ''), 
			RANGE = FIN - INI;

let tfn, n, rID = null, f = 0, typ = 0, dir = -1, 
		ini, fin, range;

function updateAng(e) {
	let _t = e.target;
		
	if(_t.type === 'range') {
		let a_new = +_t.value, name = _t.id.charAt(0);
		
		if(a_new !== VARS[name].ang) {
			VARS[name].ang = a_new;
			VARS[name].rad = VARS[name].ang*Math.PI/180;
			
			updateRangeTip(name);
		}
	}
};

function updateRangeTip(name) {
	let i = VARS[name].ang - VARS[name].sub;
	
	VARS[name].tip.textContent = VARS[name].ang;
	VARS[name].parent.style.setProperty('--val', VARS[name].ang)
};

function stopAni() {
  cancelAnimationFrame(rID);
  rID = null;  
};

function updatePrc() {
	f += dir;
	
	let k = f/NF;
  
  for(let i = 0; i < n; i++) {
		_ART[i].style.setProperty(
			'--stop', 
			`${+(INI + tfn[_ART[i].id](k)*RANGE).toFixed(2)}%`
		);
	}
  
  if(!(f%NF)) {
    stopAni();
    return;
  }
  
  rID = requestAnimationFrame(updatePrc)
};

(function init() {
	let frag = document.createDocumentFragment(), 
			_p = _RES.querySelector('p');
	
	for(let i = 0; i < N_ENDS; i++) {
		var name = END_NAMES[i]
		
		VARS[name] = {};
		
		VARS[name].range = document.getElementById(`${name}a`);
		VARS[name].parent = VARS[name].range.parentNode;
		VARS[name].ang = +VARS[name].range.value;
		VARS[name].rad = VARS[name].ang*Math.PI/180;
		VARS[name].sub = Math.min(VARS[name].range.min, VARS[name].range.max);
		VARS[name].tip = document.querySelector(`output[for='${name}a']`);
		VARS[name].o = document.getElementById(`o${name}`);
		VARS[name].p = document.getElementById(`p${name}`);
		VARS[name].px = document.getElementById(`p${name}x`);
		VARS[name].py = document.getElementById(`p${name}y`);
		
		if(name === 'e') {
			ini = +VARS[name].range.min;
			fin = +VARS[name].range.max;
			range = fin - ini;
		}
	}
	
	tfn = {
		'bounce-ini': function(k) {
			return dir > 0 ? 
				1 - Math.sin((1 - k)*VARS.s.rad)/Math.sin(VARS.s.rad) :
				Math.sin(k*-VARS.s.rad)/Math.sin(-VARS.s.rad);
		}, 
		'bounce-fin': function(k) {
			return dir > 0 ? 
				Math.sin(k*VARS.e.rad)/Math.sin(VARS.e.rad) :
				1 - Math.sin((1 - k)*-VARS.e.rad)/Math.sin(-VARS.e.rad);
		}, 
		'bounce-ini-fin': function(k) {
			return (dir > 0 ? 
				(Math.sin(k*(VARS.e.rad - VARS.s.rad) + VARS.s.rad) - Math.sin(VARS.s.rad)) :
				(Math.sin(k*(VARS.e.rad - VARS.s.rad) - VARS.e.rad) + Math.sin(VARS.e.rad)))/
				(Math.sin(VARS.e.rad) - Math.sin(VARS.s.rad));
		}
	};
	
	for(let p in tfn) {
		let art = document.createElement('article'), 
				hd = document.createElement('h3');
		
		hd.textContent = p;
		art.appendChild(hd);
		art.setAttribute('id', p);
		_ART.push(art);
		frag.appendChild(art);
	}
	
	n = _ART.length;
	_RES.insertBefore(frag, _p);
	
	addEventListener('change', updateAng, false);
	addEventListener('input', updateAng, false);
	
	_RES.addEventListener('click', e => {
		
		if(rID) stopAni();
		dir *= -1;
		updatePrc();
	}, false);
})();
              
            
!
999px

Console