cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatpop-outspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

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.

            
              $base: 1vh;
$color: white;
$dark: darken(adjust-hue($color, 20%),40%);

$ease-in: cubic-bezier(0.600, 0.040, 0.980, 0.335);
$ease-out: cubic-bezier(0.075, 0.820, 0.165, 1.000);
$ease-in-out: cubic-bezier(0.785, 0.135, 0.150, 0.860);
$short: 300ms;
$long: 2500ms;

html{
	font-size: $base;
	@media (orientation: portrait){
		font-size: 1vw;
	}
}

.Selected{
	position: absolute;
	width: 100%;
	height: 100%;
	overflow: hidden;
	&__image{
		position: absolute;
		top: 50%;
		left: 50%;
		height: 125%;
		width: 125%;
		background-size: cover;
		background-position: center;
		transform: translate3d(-50%, -50%, 0) scale(0.85);
		transition: transform $long $ease-out;
		transform-origin: 50% 50%;
	}
	
	&:before, &:after{
		content: '';
		background: $color;
		position: absolute;
		top: -2%;
		height: 104%;
		width: 102%;
	}
	&:before{
		right: 101%;
		z-index: 2;
	}
	&:after{
		left: 101%;
	}
	&--entering{
		&:before, &:after{
			transition: transform $short $ease-in-out;
		}
		&.Selected--moving{
			&-left{
				transition: transform $short $ease-in;
				&:after{transform: translateX(-100%);}
				.Selected__image{
					transform:  translate3d(-42.5%, -50%, 0) scale(0.85) skew(-5deg);
					transition: transform 1ms linear $short;
				}
			}
			&-right{
				transition: transform $short $ease-in;
				&:before{transform: translateX(100%);}
				.Selected__image{
					transform:  translate3d(-57.5%, -50%, 0) scale(0.85) skew(5deg);
					transition: transform 1ms linear $short;
				}
			}
		}
	}
		
	&--exiting{
		&:before, &:after{
			transition: transform $short $ease-in-out;
		}
		&.Selected--moving{
			&-left:after{
				transform: translateX(-200%);
			}
			&-right:before{
				transform: translateX(200%);
			}
		}
	}
	
}

.Thumb{
	position: absolute;
	bottom: 0;
	left: 50%;
	width: 16%;
	height: 80%;
	display: inline-block;
	cursor: pointer;
	transform: translateX(-100vw);
	opacity: 0;
	overflow: hidden;
	&__inner{
		position: absolute;
		width: 125%;
		height: 80%;
		top: 50%;
		left: 50%;
		background-size: cover;
		background-position: center;
		transform: scale(0.8) translate3d(-50%,-50%,0);
		transform-origin: left top;
		transition: transform $long $ease-out;
	}
	&:hover{
		.Thumb__inner{
			transition: transform $long $ease-out;
			transform: scale(1.2) translate3d(-50%,-50%,0);
		}
	}
	
	&--offset{
		&-4, &-3, &-2, &-1, &0, &1, &2, &3, &4{ 
			opacity: 1;
			transition: transform $long $ease-out, opacity $short $ease-out;
		}
	}
	&--offset-5, &--offset-6, &--offset-7{transform: translateX(-700%); }
	&--offset-4{transform: translateX(-550%); transition-delay: $short*4/8;}
	&--offset-3{transform: translateX(-425%); transition-delay: $short*3/8;}
	&--offset-2{transform: translateX(-300%); transition-delay: $short*2/8;}
	&--offset-1{transform: translateX(-175%); transition-delay: $short*1/8;}
	&--offset0{
		transform: translateX(-50%); 
		transition-delay: $short*0/8; 
		.Thumb__inner{ transform: scale(0.8) translate3d(-50%,-50%,0) !important;}
	}
	&--offset1{transform: translateX(75%); transition-delay: $short*1/8;}
	&--offset2{transform: translateX(200%); transition-delay: $short*2/8;}
	&--offset3{transform: translateX(325%); transition-delay: $short*3/8;}
	&--offset4{transform: translateX(450%); transition-delay: $short*4/8;}
	&--offset5, &--offset6, &--offset7{transform: translateX(600%);}
}

.Thumbs{
	text-align: center;
	position: relative;
	position: absolute;
	width: 100%;
	height: 100%;
	overflow: hidden;
	transform-origin: 50% 50%;
	transition: transform $long $ease-out;
	&--entering{
		transition: transform 1ms linear;
		&.Thumbs--moving{
			&-left{ transform: skewX(3deg)}
			&-right{ transform: skewX(-3deg)}
		}
	}
}

.Gallery{
	height: 60rem;
	width: 100rem;
	&__selected{
		position: absolute; 
		top: 0;
		left: 0;
		width: 100%;
		height: 75%;
	}
	&__thumbs{
		position: absolute; 
		bottom: 0;
		left: 0;
		width: 100%;
		height: 20%;
	}
}

.Center{
	position: relative;
	height: 100vh;
	width: 100vw;
	&__content{
		position: absolute;
		top: 50%;
		left: 50%;
		transform: translate3d(-50%,-50%,0);
	}
}
            
          
!
            
              console.clear();
const { Component } = React;

const Selected = (props) => {
	return (
		<div className={`Selected ${props.phase ? `Selected--${props.phase} Selected--moving-${props.direction}` : ''}`}>
			<div className="Selected__image"  style={{backgroundImage: `url(${props.src})`}}/>
		</div>
	)
}

const Thumb = (props) => {
	return (
		<div className={`Thumb Thumb--offset${props.offset}`}			
			onClick={ () => { props.select(props.index, props.offset) } }
			>
			<div className="Thumb__inner" style={{backgroundImage: `url(${props.src})`}}/>
		</div>
	);
}

const positions = [-2, -1, 0, 1, 2];

const Thumbs = (props) => {
	return (
		<div className={`Thumbs ${props.phase ? `Thumbs--${props.phase} Thumbs--moving-${props.direction}` : ''}`}>
			{props.images.map( (src, index) => {
				const count = props.images.length;
				let offset = index - props.active
				if (offset > count/2)
					offset -= count
				else if (offset < -count/2)
					offset += count
				return <Thumb src={src} 
						   key={index} 
						   index={index}
						   offset={offset}
						   select={props.select}
						   />
			})}
		</div>
	);
}


class Gallery extends Component {
	constructor(props){
		super(props);
		let loopedImages = images;
		while(loopedImages.length < 13)
			loopedImages = loopedImages.concat(props.images)
		this.state = {
			active: 0,
			showing: 0,
			phase: null,
			direction: 'left',
			loopedImages
		}
	}
	
	componentDidMount(){
		setTimeout(()=>{
			this.selectImage(1,1);		
		},1000)
	
	}
	
	selectImage(index, offset){
		if (!this.state.phase && offset !== 0){
			this.setState({ 
				active: index,
				phase: 'entering',
				direction: offset >= 0  ? 'left' : 'right'
			})
			setTimeout(()=>{
				this.setState({ 
					changing: false, 
					showing: index,
					phase: 'exiting'
				})
				setTimeout(()=>{
					this.setState({phase: null})
				}, 300)
			}, 400)
		}
	}
	
	render(){
		return (
			<div className="Gallery">
				<div className="Gallery__selected">
					<Selected src={this.state.loopedImages[this.state.showing]} 
						phase={this.state.phase} 
						direction={this.state.direction}
						/>
				</div>
				<div className="Gallery__thumbs">
					<Thumbs images={this.state.loopedImages} 
						active={this.state.active}
						select={this.selectImage.bind(this)}
						phase={this.state.phase} 
						direction={this.state.direction}
						/>
				</div>
			</div>
		)
	}
}

const Center = (props) => {
	return (
		<div className='Center'>
			<div className="Center__content">
				{props.children}
			</div>
		</div>
	)
}

const images = [
	'https://unsplash.it/1000/600?image=1069',
	'https://unsplash.it/1000/600?image=1068',
	'https://unsplash.it/1000/600?image=1081',
	'https://unsplash.it/1000/600?image=855',
	'https://unsplash.it/1000/600?image=824',
	'https://unsplash.it/1000/600?image=655',
	'https://unsplash.it/1000/600?image=881',
	'https://unsplash.it/1000/600?image=314',
	'https://unsplash.it/1000/600?image=503',
	'https://unsplash.it/1000/600?image=447',
	
]

class App extends Component {
	render(){
		return (
			<div className="App">
				<Center>
					<Gallery images={images}/>
				</Center>
			</div>
		);
	}
}

ReactDOM.render(<App />, document.querySelector(".container"));
            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console