Guest User

Untitled

a guest
Oct 21st, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. $(function() {
  2.  
  3. $('.menu__item a').on('click', function(e) {
  4. e.preventDefault();
  5.  
  6. $('.menu__item a').removeClass('active').filter(this).addClass('active');
  7.  
  8. var selector = $(this).attr('href');
  9. var goTo = $(selector);
  10.  
  11. $('html, body').animate({
  12. scrollTop: goTo.offset().top
  13. },500);
  14. });
  15.  
  16. $(window).on('scroll', function(){
  17. var $arrow = $('.arrow');
  18. var scrolled = $(this).scrollTop();
  19.  
  20. if (scrolled >= 500) {
  21. $arrow.fadeIn();
  22.  
  23. } else if (scrolled < 500) {
  24. $arrow.fadeOut();
  25. }
  26.  
  27. $arrow.on('click', function(e){
  28. e.preventDefault();
  29.  
  30. $('html, body').animate({
  31. scrollTop: 0
  32. },500);
  33. });
  34. });
  35.  
  36. $(function() {
  37.  
  38. $('.menu__item a').on('click', function(e) {
  39. e.preventDefault();
  40.  
  41. $('.menu__item a').removeClass('active').filter(this).addClass('active');
  42.  
  43. var selector = $(this).attr('href');
  44. var goTo = $(selector);
  45.  
  46. $('html, body').animate({
  47. scrollTop: goTo.offset().top
  48. },500);
  49. });
  50.  
  51. var $arrow = $('.arrow');
  52.  
  53. $arrow.on('click', function(e){
  54. e.preventDefault();
  55.  
  56. $('html, body').animate({
  57. scrollTop: 0
  58. },500);
  59. });
  60.  
  61. $(window).on('scroll', function(){
  62.  
  63. var scrolled = $(this).scrollTop();
  64.  
  65. if (scrolled >= 500) {
  66. $arrow.fadeIn();
  67.  
  68. } else if (scrolled < 500) {
  69. $arrow.fadeOut();
  70. }
  71. });
  72.  
  73.  
  74. });
Add Comment
Please, Sign In to add comment