Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Fixed left column
- $(window).scroll(function() {
- if (document.querySelector('.footer').getBoundingClientRect().top + 200 < document.querySelector('.footer').getBoundingClientRect().height) {
- $('.info-tabs').removeClass('info-tabs_active');
- } else if ($(this).scrollTop() > 290) {
- $('.info-tabs').addClass('info-tabs_active');
- } else {
- $('.info-tabs').removeClass('info-tabs_active');
- }
- var tabItems = document.querySelectorAll('.info-tabs__item'),
- tabLinks = document.querySelectorAll('.info-tabs__link'),
- tabContents = document.querySelectorAll('.info-tabs-content');
- //s_top = $('body').scrollTop(),
- yes = [];
- for (var i = 0; i <= tabItems.length; i++) {
- var tempSelector = $(`#item-${i}`);
- //yes[i] = tempSelector.offset().top;
- if (tabContents[i] != undefined || null) {
- if (tabContents[i].getBoundingClientRect().top < 100) {
- for (var j = 0; j < tabLinks.length; j++) {
- tabLinks[j].classList.remove('info-tabs__link_active');
- }
- tabLinks[i].classList.add('info-tabs__link_active');
- }
- }
- }
- });
- // Info tabs
- var infoTabsItem = document.querySelectorAll('.info-tabs__item'),
- infoTabsContent = document.querySelectorAll('.info-tabs-content');
- for (var i = 0; i < infoTabsItem.length; i++) (function(n) {
- infoTabsItem[n].addEventListener('click', function(e) {
- e.preventDefault();
- $([document.documentElement, document.body]).animate({
- scrollTop: infoTabsContent[n].offsetTop + 300
- }, 1000);
- });
- })(i);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement