Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $('.js-svg-animation').each(function () {
- var $svg = $(this);
- var $paths = $svg.find('path');
- $paths.each(function (i, path) {
- function takePathStartPosition() {
- var total_length = path.getTotalLength();
- total_length = /Firefox/i.test(navigator.userAgent) ? total_length + 22 : total_length; // firefox bug
- $(path).attr('stroke-dasharray', total_length + ' ' + total_length);
- $(path).attr('stroke-dashoffset', total_length);
- }
- takePathStartPosition(); // задаём начальное положение svg (не зарисованное)
- $(window).on('scroll', function () {
- if (!$svg.hasClass('is-ready') && $(window).scrollTop() + window.innerHeight > $svg.offset().top + 100) {
- $svg.addClass('svg-animation-path is-ready');
- $(path).attr('stroke-dashoffset', 0);
- }
- });
- });
- });
Add Comment
Please, Sign In to add comment