Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function stikySocialLInks() {
- if ( $('.social-container').length ) {
- var currentScrollTop = $(window).scrollTop(),
- viewportHeight = $(window).height(),
- article = $('.article'),
- articleOffsetTop = article.offset().top,
- socialContainer = $('.social-container'),
- articleEnd = articleOffsetTop + article.outerHeight() - socialContainer.outerHeight();
- var socialLinksHeight = $('.social-container .social-links').outerHeight(),
- socialLinksOffsetTopBase = $('.article').offset().top + parseInt(socialContainer.css('padding-top'));
- if ( currentScrollTop > viewportHeight / 2 - socialLinksHeight - 80 ) {
- socialContainer.addClass('social-container__stiky');
- }
- if ( currentScrollTop > articleEnd ) {
- socialContainer.removeClass('social-container__stiky').addClass('social-container__bottom');
- } else if ( currentScrollTop > articleOffsetTop ) {
- socialContainer.addClass('social-container__stiky').removeClass('social-container__bottom');
- } else {
- socialContainer.removeClass('social-container__stiky social-container__bottom');
- }
- }
- }
- stikySocialLInks();
- $(window).on('scroll', function() {
- stikySocialLInks();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement