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

              
                <div class="content"></div>

              
            
!

CSS

              
                html {
	height: 100%;
}

body {
	background-color: #333;
	margin: 0;
	padding: 0;
	height: 100%;

	font-family: arial !important;
}

.content {
	width: 100%;
	height: 100%;
}

.wrapper {
	width: 30%;
	height: 100%;
	box-sizing: border-box;
	overflow: hidden;
	padding: 30px 0;
	max-width: 400px;
	min-width: 300px;
	position: relative;
	background-color: #a10000;
}

.wrapper__list {
	margin: 0;
}

.navigation__items {
	display: none;
	left: 100%;
	width: 100%;
	box-sizing: border-box;
}

.navigation__items > li {
	list-style: none;
	margin: 10px 0 20px 0;
	cursor: pointer;

	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	-o-user-select: none;
	user-select: none;
}

.navigation__items > li.fade__in--left {
	opacity: 1;
	-webkit-animation: fadeInLeft 1s cubic-bezier(0.55, 0.01, 0.28, 0.82);
	animation: fadeInLeft 1s cubic-bezier(0.55, 0.01, 0.28, 0.82);
}

.navigation__items > li.fade__in--right {
	opacity: 1;
	-webkit-animation: fadeInRight 1s cubic-bezier(0.55, 0.01, 0.28, 0.82);
	animation: fadeInRight 1s cubic-bezier(0.55, 0.01, 0.28, 0.82);
}

.navigation__items > li.fade__out--left {
	opacity: 0;
	-webkit-animation: fadeOutLeft 1s cubic-bezier(0.55, 0.01, 0.28, 0.82);
	animation: fadeOutLeft 1s cubic-bezier(0.55, 0.01, 0.28, 0.82);
}

.navigation__items > li.fade__out--right {
	opacity: 0;
	-webkit-animation: fadeOutRight 1s cubic-bezier(0.55, 0.01, 0.28, 0.82);
	animation: fadeOutRight 1s cubic-bezier(0.55, 0.01, 0.28, 0.82);
}

.navigation__items--active {
	display: block;
}

.navigation__path > li {
	list-style: none;
	display: inline-block;
	cursor: pointer;

	font-size: 20px;
	color: rgba(0, 0, 0, 0.2);

	-webkit-transition: all 0.4s;
	-o-transition: all 0.4s;
	transition: all 0.4s;

	-webkit-user-select: none;
	-moz-user-select: none;
	-ms-user-select: none;
	-o-user-select: none;
	user-select: none;
}

.navigation__path > li.appear {
	opacity: 1;
	-webkit-animation: appear 0.4s cubic-bezier(0.55, 0.01, 0, 1.39);
	animation: appear 0.4s cubic-bezier(0.55, 0.01, 0, 1.39);
}

.navigation__path > li.disappear {
	opacity: 0;
	-webkit-animation: disappear 0.4s cubic-bezier(0.55, 0.01, 0.28, 0.82);
	animation: disappear 0.4s cubic-bezier(0.55, 0.01, 0.28, 0.82);
}

.navigation__path > li:hover {
	text-decoration: underline;
	color: rgba(0, 0, 0, 1);
}

.navigation__path > li.current {
	color: rgba(0, 0, 0, 1);
}

.navigation__path > li.current:hover {
	text-decoration: none;
	color: rgba(0, 0, 0, 1);
}

.navigation__item--multiple::after {
	content: "";
	width: 0;
	height: 0;
	border: 4px solid transparent;
	border-left: 4px solid #000;
	vertical-align: middle;
	display: inline-block;
	margin-left: 5px;
}

.navigation__path--has-before::before {
	content: '>';
	display: inline-block;
	padding: 0 0.5em;
	color: rgba(0, 0, 0, 0.2);
}

.block__wrapper {
	margin: 30px 0;	
}

/** fade out animations */
@keyframes fadeOutLeft {
	0% {
		transform: translateX(0);
		opacity: 1;
	}

	100% {
		transform: translateX(-100%);
		opacity: 0;
	}
}

@-webkit-keyframes fadeOutLeft {
	0% {
		transform: translateX(0);
		opacity: 1;
	}

	100% {
		transform: translateX(-100%);
		opacity: 0;
	}
}

@keyframes fadeOutRight {
	0% {
		transform: translateX(0);
		opacity: 1;
	}

	100% {
		transform: translateX(100%);
		opacity: 0;
	}
}

@-webkit-keyframes fadeOutRight {
	0% {
		transform: translateX(0);
		opacity: 1;
	}

	100% {
		transform: translateX(100%);
		opacity: 0;
	}
}

/** fade in animations */
@keyframes fadeInLeft {
	0% {
		transform: translateX(50%);
		opacity: 0;
	}

	100% {
		transform: translateX(0);
		opacity: 1;
	}
}

@-webkit-keyframes fadeInLeft {
	0% {
		transform: translateX(50%);
		opacity: 0;
	}

	100% {
		transform: translateX(0);
		opacity: 1;
	}
}

@keyframes fadeInRight {
	0% {
		transform: translateX(-50%);
		opacity: 0;
	}

	100% {
		transform: translateX(0);
		opacity: 1;
	}
}

@-webkit-keyframes fadeInRight {
	0% {
		transform: translateX(-50%);
		opacity: 0;
	}

	100% {
		transform: translateX(0);
		opacity: 1;
	}
}

/** appearance animations */
@keyframes appear {
	0% {
		transform: scale(0.2);
		opacity: 0;
	}

	100% {
		transform: scale(1);
		opacity: 1;
	}
}

@-webkit-keyframes appear {
	0% {
		transform: scale(0.2);
		opacity: 0;
	}

	100% {
		transform: scale(1);
		opacity: 1;
	}
}

@keyframes disappear {
	0% {
		transform: scale(1);
		opacity: 1;
	}

	100% {
		transform: scale(0.2);
		opacity: 0;
	}
}

@-webkit-keyframes disappear {
	0% {
		transform: scale(1);
		opacity: 1;
	}

	100% {
		transform: scale(0.2);
		opacity: 0;
	}
}

              
            
!

JS

              
                /** public methods */
HTMLElement.prototype.hasClassName = function (name) {
	return new RegExp('(\\s|^)' + name + '(\\s|$)').test(this.className);
};

HTMLElement.prototype.addClass = function (name) {
	if (!this.hasClassName(name)) {
		this.className += ' ' + name;
	}
};

HTMLElement.prototype.removeClass = function (name) {
	if (this.hasClassName(name)) {
		var reg = new RegExp('(\\s|^)' + name + '(\\s|$)');
		this.className = this.className.replace(reg,' ').trim();
	}
};

/** logical start */
var data = {
	name: 'ALL',
	children: [
		{ name: 'item1', children: null },
		{ name: 'item2', children: [
			{ name: 'item12', children: null },
			{ name: 'item13', children: null }
		]},
		{ name: 'item3', children: [
			{ name: 'item4', children: null },
			{ name: 'item5', children: [
				{ name: 'item7', children: null },
				{ name: 'item8', children: null }
			]},
			{ name: 'item6', children: [
				{ name: 'item9', children: null }
			]},
			{ name: 'item10', children: [
				{ name: 'item11', children: null }
			]}
		]}
	]
};

class Navigation extends React.Component {
	constructor(props) {
		super(props);

		this.path = [
			this.props.data.name
		];

		this.state = {
			name: this.props.data.name
		};

		this.isLeft = true;
		this.appear = true;
	}

	componentWillUpdate(nextProps, nextState) {
		/** reset delay time */
		var moveItems = document.querySelectorAll('.navigation__items--active > li');
		var moveItemsLen = moveItems.length;

		for (var j = 0; j < moveItemsLen; j++) {
			moveItems[j].style['animation-delay'] = j * -0.06 + 's';
			moveItems[j].style['-webkit-animation-delay'] = j * -0.06 + 's';
		}

		/** update path */
		var index = this.path.indexOf(nextState.name);

		if (index >= 0) {
			this.path = this.path.slice(0, index + 1);
		} else {
			this.path = this.path.concat(nextState.name);
		}
	}

	render() {
		var items = [];

		var recursive = function (parent) {
			if (!parent.children) {
				return;
			}

			var children = parent.children;
			var childLen = children.length;
			var childItems = [];

			for (var i = 0; i < childLen; i++) {
				childItems.push(<li key={i} className={'' + (children[i].children ? 'navigation__item--multiple' : '') + (this.state.name === parent.name ? (this.isLeft ? ' fade__in--left' : ' fade__in--right'): '')} onClick={
							children[i].children ? (function (thisArg, name, i) {
								return function () {
									this.isLeft = true;
									this.appear = true;

									var moveItems = document.querySelectorAll('.navigation__items--active > li');
									var moveItemsLen = moveItems.length;

									/** set delay time */
									var range = Math.max(Math.abs(i - moveItems.length), i + 1);

									for (var j = 0; j < range; j++) {
										if (typeof moveItems[i - j] !== 'undefined') {
											moveItems[i - j].style['animation-delay'] = (range - 1 - j) * -0.06 + 's';
											moveItems[i - j].style['-webkit-animation-delay'] = (range - 1 - j) * -0.06 + 's';
										}

										if (typeof moveItems[i + j] !== 'undefined') {
											moveItems[i + j].style['animation-delay'] = (range - 1 - j) * -0.06 + 's';
											moveItems[i + j].style['-webkit-animation-delay'] = (range - 1 - j) * -0.06 + 's';
										}
									}

									/** fade out */
									for (var k = 0; k < moveItemsLen; k++) {
										moveItems[k].addClass('fade__out--left');
									}

									setTimeout(function () {
										this.setState({
											name
										});	
									}.bind(this), 300);
								}.bind(thisArg);
							})(this, children[i].name, i) : null
						} style={{
							animationDelay: i * -0.06 + 's',
								WebkitAnimationDelay: i * -0.06 + 's'
						}}>{children[i].name}</li>);
				recursive(children[i]);
			}

			items.push(<ul className={'wrapper__list navigation__items ' + (this.state.name === parent.name ? 'navigation__items--active' : '')} key={items.length}>{childItems}</ul>);
		}.bind(this);

		recursive(this.props.data);

		return (
			<div className="wrapper">
				<div className="block__wrapper">
					<ul className="wrapper__list navigation__path">{
							this.path.map((ele, index) => (
								<li key={index} className={'' + (index > 0 ? 'navigation__path--has-before' : '') + (index === this.path.length - 1 ? ' current' : '') + (index === this.path.length - 1 && this.appear ? ' appear' : '')} onClick={
										function () {
											if (this.state.name === ele) {
												return;
											}

											this.isLeft = false;
											this.appear = false;

											/** fade out */
											var moveItems = document.querySelectorAll('.navigation__items--active > li');
											var moveItemsLen = moveItems.length;

											for (var i = 0; i < moveItemsLen; i++) {
												moveItems[i].addClass('fade__out--right');
											}

											/** disappear paths */
											var disappearItems = 
											    document.querySelectorAll('.navigation__path > li');
											var disappearItemsLen = disappearItems.length;

											for (var i = disappearItemsLen - 1; i > 0; i--) {
												if (disappearItems[i].innerText === ele) {
													break;
												}

												disappearItems[i].addClass('disappear');
											}


											setTimeout(function () {
												this.setState({
													name: ele
												});	
											}.bind(this), 300);
										}.bind(this)
									}>{ele}</li>
							))
						}
					</ul>
				</div>
				<div className="block__wrapper">{items}</div>
			</div>
		);
	}
}

Navigation.defaultProps = {
	data
};

Navigation.PropTypes = {
	data: React.PropTypes.object
};

ReactDOM.render(
	<Navigation data={data}></Navigation>,
	document.querySelector('.content')
);

              
            
!
999px

Console