Super Starter Fully Loaded Bootstrap Template – Ready to go!!!
Copy and paste below code to your HTML file
<!doctype html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/animate.css/3.7.0/animate.min.css">
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.5.0/css/all.css" integrity="sha384-B4dIYHKNBt8Bc12p+WXckhzcICo0wtJAoU8YZTY5qE0Id1GSseTk6S+L3BlXeVIU" crossorigin="anonymous">
<link rel="stylesheet" href="./assets/css/style.css">
<title>Hello, world!</title>
</head>
<body>
<h1>Hello, world!</h1>
<!-- Optional JavaScript -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js"></script>
<script src="./assets/js/common.js"></script>
</body>
</html>
Add this jQuery code to ‘common.js’ file
/* jQuery to animate element on viewport */
(function($){
function onScrollInit( items, trigger ) {
items.each( function() {
var osElement = $(this),
osAnimationClass = osElement.attr('data-os-animation'),
osAnimationDelay = osElement.attr('data-os-animation-delay');
osElement.css({
'-webkit-animation-delay': osAnimationDelay,
'-moz-animation-delay': osAnimationDelay,
'animation-delay': osAnimationDelay
});
var osTrigger = ( trigger ) ? trigger : osElement;
osTrigger.waypoint(function() {
osElement.addClass('animated').addClass(osAnimationClass);
},{
triggerOnce: true,
offset: '90%'
});
});
}
$(document).ready(function(){
onScrollInit( $('.os-animation') );
onScrollInit( $('.staggered-animation'), $('.staggered-animation-container') );
});
})(jQuery);
Add this style to the main CSS file
.os-animation{
opacity: 0;
}
.os-animation.animated{
opacity: 1;
}
Add the following attributes to HTML elements to animate on the viewport
class=”os-animation” data-os-animation=”zoomIn” data-os-animation-delay=”0s”
References:
https://www.oxygenna.com/tutorials/scroll-animations-using-waypoints-js-animate-css
https://getbootstrap.com/ https://fontawesome.com/
http://imakewebthings.com/waypoints/
https://daneden.github.io/animate.css/
You must be logged in to post a comment.