코드랩 레퍼런스

Parallax - Text Animation - letter2 본문

SAMPLE

Parallax - Text Animation - letter2

webstoryboy 2018. 2. 8. 20:45

See the Pen Parallax - Text Animation - letter2 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,#eb3941,#f15e64,#e2373f);}
		#section2 {background: linear-gradient(135deg,#b1ea4d,#459522);}
		#section3 {background: linear-gradient(135deg,#f54ea2,#ff7676);}
		#section4 {background: linear-gradient(135deg,#65799b,#5e2563);}
		#section5 {background: linear-gradient(135deg,#FD6E6A,#FFC600);}
		#section6 {background: linear-gradient(135deg,#6e8efb,#a777e3);}


		h2 span {opacity: 0; display: inline-block;}
		.sec1 h2 span.show {
			animation: ani1 .3s forwards;
		}
		.sec2 h2 span.show {
			animation: ani2 .45s forwards;
			transform: translate(-150px, -50px) rotate(-180deg) scale(3);
		}
		.sec3 h2 span.show {
			animation: ani3 .3s forwards;
			transform: translate(200px, -100px) scale(2);
		}
		.sec4 h2 span.show {
			animation: ani4 .5s forwards;
			transform: translate(-300px, 0) scale(0);
		}
		.sec5 h2 span.show {
			animation: ani5 .8s forwards;
			transform: translate(0, -100px) rotate(360deg) scale(0);
		}
		.sec6 h2 span.show {
			animation: ani6 .5s forwards;
			transform: translate(0, -100px) rotate(360deg) scale(0);
		}
		@keyframes ani1 {
			0% {opacity: 0 ; transform: translatey(50px)}
			100% {opacity: 1; transform: translatey(0px)}
		}
		@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){
				$(".sec1 h2 span").each(function(i){
					setTimeout(function(){
						$(".sec1 h2 span").eq(i).addClass("show");					 
					},100*(i+1));
				});
			}
			if(wScroll > contents.eq(1).offset().top - $(window).height()/3){
				$(".sec2 h2 span").each(function(i){
					setTimeout(function(){
						$(".sec2 h2 span").eq(i).addClass("show");					 
					},100*(i+1));
				});
			}
			if(wScroll > contents.eq(2).offset().top - $(window).height()/3){
				$(".sec3 h2 span").each(function(i){
					setTimeout(function(){
						$(".sec3 h2 span").eq(i).addClass("show");					 
					},100*(i+1));
				});
			}
			if(wScroll > contents.eq(3).offset().top - $(window).height()/3){
				$(".sec4 h2 span").each(function(i){
					setTimeout(function(){
						$(".sec4 h2 span").eq(i).addClass("show");					 
					},100*(i+1));
				});
			}
			if(wScroll > contents.eq(4).offset().top - $(window).height()/3){
				$(".sec5 h2 span").each(function(i){
					setTimeout(function(){
						$(".sec5 h2 span").eq(i).addClass("show");					 
					},100*(i+1));
				});
			}
			if(wScroll > contents.eq(5).offset().top - $(window).height()/3){
				$(".sec6 h2 span").each(function(i){
					setTimeout(function(){
						$(".sec6 h2 span").eq(i).addClass("show");					 
					},100*(i+1));
				});
			}
		});
	</script>
</body>
</html>

Share

Ad

Comments