Advertisement
Guest User

Untitled

a guest
Mar 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. // Fixed left column
  2.  
  3. $(window).scroll(function() {
  4. if (document.querySelector('.footer').getBoundingClientRect().top + 200 < document.querySelector('.footer').getBoundingClientRect().height) {
  5. $('.info-tabs').removeClass('info-tabs_active');
  6. } else if ($(this).scrollTop() > 290) {
  7. $('.info-tabs').addClass('info-tabs_active');
  8. } else {
  9. $('.info-tabs').removeClass('info-tabs_active');
  10. }
  11.  
  12. var tabItems = document.querySelectorAll('.info-tabs__item'),
  13. tabLinks = document.querySelectorAll('.info-tabs__link'),
  14. tabContents = document.querySelectorAll('.info-tabs-content');
  15. //s_top = $('body').scrollTop(),
  16. yes = [];
  17.  
  18. for (var i = 0; i <= tabItems.length; i++) {
  19. var tempSelector = $(`#item-${i}`);
  20. //yes[i] = tempSelector.offset().top;
  21.  
  22. if (tabContents[i] != undefined || null) {
  23. if (tabContents[i].getBoundingClientRect().top < 100) {
  24. for (var j = 0; j < tabLinks.length; j++) {
  25. tabLinks[j].classList.remove('info-tabs__link_active');
  26. }
  27.  
  28. tabLinks[i].classList.add('info-tabs__link_active');
  29. }
  30. }
  31. }
  32. });
  33.  
  34. // Info tabs
  35.  
  36. var infoTabsItem = document.querySelectorAll('.info-tabs__item'),
  37. infoTabsContent = document.querySelectorAll('.info-tabs-content');
  38.  
  39. for (var i = 0; i < infoTabsItem.length; i++) (function(n) {
  40. infoTabsItem[n].addEventListener('click', function(e) {
  41. e.preventDefault();
  42. $([document.documentElement, document.body]).animate({
  43. scrollTop: infoTabsContent[n].offsetTop + 300
  44. }, 1000);
  45. });
  46. })(i);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement