Simple scroll controlled animation

Size
2,229 Kb
Views
10,120

How do I make an simple scroll controlled animation?

GreenSock forums:http://greensock.com/forums/topic/11171-fade-in-on-scroll/. What is a simple scroll controlled animation? How do you make a simple scroll controlled animation? This script and codes were developed by Rodrigo Hernando on 18 November 2022, Friday.

Simple scroll controlled animation Previews

Simple scroll controlled animation - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Simple scroll controlled animation</title> <style> /* NOTE: The styles were added inline because Prefixfree needs access to your styles and they must be inlined if they are on local disk! */ html,body{ margin:0; padding:0;
}
.height-marker{ height:2000px; width:1px; position:absolute; visibility:hidden;
}
#target{ width:300px; height:50px; background:blue; position:fixed; margin:50px; border-radius:10px;
} </style> <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script>
</head>
<body> <div id="target"></div>
<div class="height-marker"></div> <script src='http://cdnjs.cloudflare.com/ajax/libs/jquery/2.1.3/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/gsap/1.15.0/TweenMax.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

Simple scroll controlled animation - Script Codes CSS Codes

html,body{ margin:0; padding:0;
}
.height-marker{ height:2000px; width:1px; position:absolute; visibility:hidden;
}
#target{ width:300px; height:50px; background:blue; position:fixed; margin:50px; border-radius:10px;
}

Simple scroll controlled animation - Script Codes JS Codes

var t = TweenLite.from("#target", 1,{ autoAlpha:0, x:150, paused:true, ease:Linear.easeNone
}), scrollThreshold = {"start":201, "stop":600};
$(window).on("scroll",function(e){ var currentScroll = $(window).scrollTop(), currentProgress = ( currentScroll - scrollThreshold.start ) / ( scrollThreshold.stop - scrollThreshold.start ); if(currentScroll > scrollThreshold.start && currentScroll < scrollThreshold.stop){ t.progress(currentProgress); }else if( currentScroll < scrollThreshold.start ){ t.progress(0); }else if( currentScroll < scrollThreshold.stop ){ t.progress(1); }
});
Simple scroll controlled animation - Script Codes
Simple scroll controlled animation - Script Codes
Home Page Home
Developer Rodrigo Hernando
Username rhernando
Uploaded November 18, 2022
Rating 3
Size 2,229 Kb
Views 10,120
Do you need developer help for Simple scroll controlled 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!

Rodrigo Hernando (rhernando) Script Codes
Create amazing blog posts 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!