Last active
December 17, 2020 20:01
-
-
Save Scretch-1/e5f28c04ece93051b177 to your computer and use it in GitHub Desktop.
Анимация блоков при скролле страницы
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Для начала подключаем animate_plugin | |
//Далее подключаем плагин waypoints https://github.com/imakewebthings/waypoints | |
//Далее на странице подключаем "animate" стили в | |
<head> | |
<link rel="stylesheet" href="libs/animate-plugin/animate.min.css"> | |
</head> | |
//После в самом низу тега | |
<body> | |
<script type="text/javascript" src="libs/animate-plugin/animate-css.js"></script> | |
<script type="text/javascript" src="libs/animate-plugin/jquery.waypoints.min.js"></script> | |
</body | |
//В файле "common.js" прописываем функцию вызова плагина | |
$(document).ready(function(){ | |
$("section h2").animated("zoomInUp"); | |
}) | |
//--HTML--// | |
//Пример применения | |
<section class="s_1" style="height: 800px;"> | |
<h2>Section Header</h2> | |
</section> | |
<section class="s_2" style="height: 800px;"> | |
<h2>Section Center</h2> | |
</section> | |
<section class="s_3" style="height: 800px;"> | |
<h2>Section Content</h2> | |
</section> | |
<section class="s_4" style="height: 800px;"> | |
<h2>Section Footer</h2> | |
</section> | |
//--end HTML--// | |
//--JS--// | |
//Animate CSS + WayPoints javaScript Plugin | |
//Example: $(".element").animated("zoomInUp", "zoomOutDown"); | |
//Урок http://webdesign-master.ru/blog/html-css/22.html | |
(function($) { | |
$.fn.animated = function(inEffect) { | |
$(this).each(function() { | |
var ths = $(this); | |
ths.css("opacity", "0").addClass("animated").waypoint(function(dir) { | |
if (dir === "down") { | |
ths.addClass(inEffect).css("opacity", "1"); | |
}; | |
}, { | |
offset: "90%" | |
}); | |
}); | |
}; | |
})(jQuery); | |
//--end JS--// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment