코드랩 레퍼런스

Parallax - Text Animation - letter 본문

SAMPLE

Parallax - Text Animation - letter

webstoryboy 2018. 2. 8. 20:03

See the Pen Parallax Text Animation - letter by Webstoryboy (@webstoryboy) on CodePen.

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		@import url('https://fonts.googleapis.com/css?family=Vidaloka');
		/* font-family: 'Vidaloka', serif; */

		/* reset */
		*{margin:0; padding:0}
		li,ul {list-style:none}
		a {text-decoration:none}

		/* dot */
		#dot {
			position: fixed; 
			right:20px; top: 50%; 
			z-index: 1000;
			transform: translatey(-50%);
		}
		#dot li {
			position: relative;
			display: block;
			width: 16px; height: 16px; 
			border-radius:50%; 
			margin:8px; 
			box-shadow: 0 0 0 2px rgba(255, 255, 255, 0); 
			transition: box-shadow 0.3s ease;
		}
		#dot li a {
			background-color: rgba(255, 255, 255, 0.7);
			transition: background-color 0.3s ease, transform 0.3s ease;
			top: 0; left: 0;
			width: 100%;
			height: 100%;
			outline: none;
			border-radius: 50%;
			background-color: #fff;
			background-color: rgba(255, 255, 255, 0.3);
			text-indent: -999em;
			cursor: pointer;
			position: absolute;
		}
		#dot li.active {
			box-shadow: 0 0 0 2px white;
		}
		#dot li.active a {
			transform: scale(0.4);
		}
		#dot li a em {
			opacity:0; 
			position: absolute; right: 37px; top:-7px; 
			background: rgba(0,0,0,0.55); 
			color:#fff; 
			padding: 8px 14px 5px 14px; 
			display:block; 
			transition: all 0.3s ease; opacity:0;
		}
		/* contents */
		#contents {
			font-size: 40px; 
			color:#fff; 
			text-align: center; 
			font-family: 'Vidaloka', serif;
			font-style: italic;
		}
		#contents > div {
			position: relative;
			height: 100vh; line-height: 100vh;
		}
		/* section */
		#section1 {background: linear-gradient(135deg,#65799b,#5e2563);}
		#section2 {background: linear-gradient(135deg,#b1ea4d,#459522);}
		#section3 {background: linear-gradient(135deg,#f54ea2,#ff7676);}
		#section4 {background: linear-gradient(135deg,#eb3941,#f15e64,#e2373f);}
		#section5 {background: linear-gradient(135deg,#FD6E6A,#FFC600);}
		#section6 {background: linear-gradient(135deg,#6e8efb,#a777e3);}

		.sec1 .animate.show span {animation: ani1 .35s ease forwards;}
		.sec2 .animate.show span {
			animation: ani2 .4s forwards; 
			transform: translate(-150px, -50px) rotate(-180deg) scale(3);
		}
		.sec3 .animate.show span {
			animation: ani3 .3s forwards;
			transform: translate(200px, -100px) scale(2);
		}
		.sec4 .animate.show span {
			animation: ani4 .5s forwards;
			transform: translate(-300px, 0) scale(0);
		}
		.sec5 .animate.show span {
			animation: ani5 .8s forwards;
			transform: translate(0, -100px) rotate(360deg) scale(0);
		}
		.sec6 .animate.show span {
			animation: ani6 .5s forwards;
			transform: translate(0, -100px) rotate(360deg) scale(0);
		}
		.animate span {opacity: 0; display: inline-block;}
		.animate.show span:nth-of-type(1) {animation-delay: 0s;}
		.animate.show span:nth-of-type(2) {animation-delay: .05s;}
		.animate.show span:nth-of-type(3) {animation-delay: .1s;}
		.animate.show span:nth-of-type(4) {animation-delay: .15s;}
		.animate.show span:nth-of-type(5) {animation-delay: .2s;}
		.animate.show span:nth-of-type(6) {animation-delay: .25s;}
		.animate.show span:nth-of-type(7) {animation-delay: .3s;}
		.animate.show span:nth-of-type(8) {animation-delay: .35s;}
		.animate.show span:nth-of-type(9) {animation-delay: .4s;}
		.animate.show span:nth-of-type(10){animation-delay: .45s;}
		.animate.show span:nth-of-type(11){animation-delay: .5s;}
		.animate.show span:nth-of-type(12){animation-delay: .55s;}
		.animate.show span:nth-of-type(13){animation-delay: .6s;}
		.animate.show span:nth-of-type(14){animation-delay: .65s;}
		.animate.show span:nth-of-type(15){animation-delay: .7s;}
		.animate.show span:nth-of-type(16){animation-delay: .75s;}
		.animate.show span:nth-of-type(17){animation-delay: .8s;}
		.animate.show span:nth-of-type(18){animation-delay: .85s;}
		.animate.show span:nth-of-type(19){animation-delay: .9s;}
		.animate.show span:nth-of-type(20){animation-delay: .95s;}
		.animate.show span:nth-of-type(21){animation-delay: 1s;}

		@keyframes ani1 {
			0% {opacity: 0}
			100% {opacity: 1;}
		}
		@keyframes ani2 {
			60% {transform: translate(20px, 20px) rotate(30deg) scale(.3);}
			100% {transform: translate(0) rotate(0) scale(1); opacity: 1;}
		}
		@keyframes ani3 {
			60% {transform: translate(0, 20px) rotate(-180deg) scale(.5);}
			100% {transform: translate(0) rotate(0deg) scale(1); opacity: 1;}
		}
		@keyframes ani4 {
			60% {transform: translate(20px, 0) scale(1); color: #b10e81;}
			80% {transform: translate(20px, 0) scale(1); color: #b10e81;}
			99% {transform: translate(0) scale(1.2); color: #00f0ff;}
			100% {transform: translate(0) scale(1); color: #fff; opacity: 1;}
		}
		@keyframes ani5 {
			30% {transform: translate(0, -50px) rotate(180deg) scale(1);}
			60% {transform: translate(0, 20px) scale(.8) rotate(0deg);}
			100% {transform: translate(0) scale(1) rotate(0deg); opacity: 1;}
		}
		@keyframes ani6 {
			30% {transform: translate(0, -50px) rotate(180deg) scale(1);}
			50% {transform: translate(0, 20px) scale(.8) rotate(0deg); opacity: 1;}
			80% {transform: translate(-100px, -100px) scale(1.5) rotate(-180deg); opacity: 0;}
			100% {transform: translate(0) scale(1) rotate(0deg); opacity: 1;}
		}
	</style>
</head>
<body>
	<nav id="dot">
		<ul>
			<li class="active"><a href="#"><em>Intro</em></a></li>
			<li><a href="#"><em>Skill</em></a></li>
			<li><a href="#"><em>Website</em></a></li>
			<li><a href="#"><em>Work</em></a></li>
			<li><a href="#"><em>About</em></a></li>
			<li><a href="#"><em>Contact</em></a></li>
		</ul>
	</nav>

	<section id="contents">
		<div id="section1">
			<div class="container">
				<div class="sec1">
					<h2 class="animate ">
						<span>N</span><span>e</span><span>v</span><span>e</span><span>r</span> <span>s</span><span>a</span><span>y</span> <span>n</span><span>e</span><span>v</span><span>e</span><span>r</span><span>.</span>
					</h2>
				</div>
			</div>
		</div>
		<div id="section2">
			<div class="container">
				<div class="sec2">
					<h2 class="animate">
						<span>L</span><span>o</span><span>v</span><span>e</span> <span>c</span><span>o</span><span>n</span><span>q</span><span>u</span><span>e</span><span>s</span> <span>a</span><span>l</span><span>l</span><span>.</span>
					</h2>
				</div>
			</div>
		</div>
		<div id="section3">
			<div class="container">
				<div class="sec3">
					<h2 class="animate">
						<span>E</span><span>v</span><span>e</span><span>r</span><span>y</span> <span>w</span><span>a</span><span>l</span><span>l</span> <span>i</span><span>s</span> <span>a</span> <span>d</span><span>o</span><span>o</span><span>r</span><span>.</span>
					</h2>
				</div>
			</div>
		</div>
		<div id="section4">
			<div class="container">
				<div class="sec4">
					<h2 class="animate">
						<span>D</span><span>o</span><span>n</span><span>'</span><span>t</span> <span>d</span><span>r</span><span>e</span><span>a</span><span>m</span> 	<span>i</span><span>t</span><span>,</span>
	 <span>b</span><span>e</span> <span>i</span><span>t</span><span>.</span>
					</h2>
				</div>
			</div>
		</div>
		<div id="section5">
			<div class="container">
				<div class="sec5">
					<h2 class="animate">
						<span>D</span><span>o</span> <span>i</span><span>t</span> <span>N</span><span>o</span><span>w</span><span>!</span>
					</h2>
				</div>
			</div>
		</div>
		<div id="section6">
			<div class="container">
				<div class="sec6">
					<h2 class="animate">
						<span>P</span><span>r</span><span>a</span><span>c</span><span>t</span><span>i</span><span>c</span><span>e</span> <span>m</span><span>a</span><span>k</span><span>e</span><span>s</span> <span>p</span><span>e</span><span>r</span><span>f</span><span>e</span><span>c</span><span>t</span><span>.</span>
					</h2>
			</div>
		</div>
	</section>
	
	<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
	<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
	<script>
		var dot = $("#dot ul li");
		var contents = $("#contents > div");

		dot.click(function(e){
			e.preventDefault();
			var target = $(this);
			var index = target.index();
			var section = contents.eq(index);
			var offset = section.offset().top;
			$("html,body").animate({scrollTop:offset},600,"easeInOutExpo");
		});

		$(window).scroll(function(){
			var wScroll = $(this).scrollTop();

			if(wScroll >= contents.eq(0).offset().top){
				dot.removeClass("active");
				dot.eq(0).addClass("active");
			}
			if(wScroll >= contents.eq(1).offset().top){
				dot.removeClass("active");
				dot.eq(1).addClass("active");
			}
			if(wScroll >= contents.eq(2).offset().top){
				dot.removeClass("active");
				dot.eq(2).addClass("active");
			}
			if(wScroll >= contents.eq(3).offset().top){
				dot.removeClass("active");
				dot.eq(3).addClass("active");
			}
			if(wScroll >= contents.eq(4).offset().top){
				dot.removeClass("active");
				dot.eq(4).addClass("active");
			}
			if(wScroll >= contents.eq(5).offset().top){
				dot.removeClass("active");
				dot.eq(5).addClass("active");
			}
			
			if(wScroll >= contents.eq(0).offset().top - $(window).height()/3){
				contents.eq(0).find("h2").addClass("show");
			}
			if(wScroll >= contents.eq(1).offset().top - $(window).height()/3){
				contents.eq(1).find("h2").addClass("show");
			}
			if(wScroll >= contents.eq(2).offset().top - $(window).height()/3){
				contents.eq(2).find("h2").addClass("show");
			}
			if(wScroll >= contents.eq(3).offset().top - $(window).height()/3){
				contents.eq(3).find("h2").addClass("show");
			}
			if(wScroll >= contents.eq(4).offset().top - $(window).height()/3){
				contents.eq(4).find("h2").addClass("show");
			}
			if(wScroll >= contents.eq(5).offset().top - $(window).height()/3){
				contents.eq(5).find("h2").addClass("show");
			}
		});
	</script>
</body>
</html>

Share

Ad

Comments