Page Header animation

2,828 Kb

How do I make an page header animation?

I had to create a very fast and optimized page that had a sophisticated header on-scroll animation ( like 3D parallax ). I could add TweenLite+CSSPlugin ( 21.09KB ), but decided to add nothing more. So this is kind of the most simple, Vanilla JS, yet very flexible and fast header scroll-in effect;. What is a page header animation? How do you make a page header animation? This script and codes were developed by Chrysto on 16 July 2022, Saturday.

Page Header animation Previews

Page Header animation - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Page Header animation</title> <script src="" type="text/javascript"></script> <link rel="stylesheet" href=""> <link rel="stylesheet" href="css/style.css">
<body> <header> <div id="box1"></div> <div id="box2"></div> <div id="box3"></div>
</header> <script src=''></script>
<script src=''></script> <script src="js/index.js"></script>

Page Header animation - Script Codes CSS Codes

body {	min-height:2000px;
header {	position:absolute;	top:0;	left:0;	width:100%;	height:500px;	background-color:#e7e7e7; overflow: hidden;
div[id^=box]{ position: absolute;
#box1 {	left:10%;	bottom:20%;	width:300px;	height:300px;	background-color:red;
#box2 {	top:10%;	left:40%;	width:200px;	height:130px;	background-color:#000;
#box3 {	top:30%;	right:20%;	width:12%;	height:17%;	background-color:green;

Page Header animation - Script Codes JS Codes

document.addEventListener("DOMContentLoaded", function(){ //needed to get scrollTop position on IE9- var documentElement = document.documentElement; //Heder height var targetPosY = 500; /* A couple of notes here 1) For such a thing, normally I would just use a TimelineMax. It is amazingly flexible and is tend for just this kind of animations. The idea of this pen is to make things fast and simple as possible; 2) Actually, I can pass string to"element ID", time, {...}); but I prefer to pass DOM Element 3) If you add your own TweenLite's and style it, actually can get pritty nice results */ var tweens = [ document.querySelector("#box1"), 1, {css:{force3D:true, scale:1.2, y:100}, paused:true}), document.querySelector("#box2"), 1, {css:{force3D:true, scale:1.6, y:200, x:-100, alpha: 0.5}, paused:true}), document.querySelector("#box3"), 1, {css:{force3D:true, scale:2.6, y:150, x:50, rotation:45}, paused:true}) ]; window.onscroll = function (event) { ( !! window.requestAnimationFrame) ? requestAnimationFrame(onScroll) : onScroll(); } function onScroll(){ //have to restrict it into range, because on OSX it can get negative values // var top = Math.max(Math.min(window.pageYOffset || documentElement.scrollTop, targetPosY), 0); if(top <= targetPosY){ var progress = (top / targetPosY);, function(tween){ tween.progress(progress); }); } }
});//end on DOMContentLoaded
Page Header animation - Script Codes
Page Header animation - Script Codes
Home Page Home
Developer Chrysto
Username bassta
Uploaded July 16, 2022
Rating 3.5
Size 2,828 Kb
Views 48,576
Do you need developer help for Page Header animation?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Chrysto (bassta) Script Codes
Create amazing video scripts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!