Advertisement
devinb93

Recruitment Funnel Footer Tracking Code

Nov 12th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1.  
  2. <script>
  3. //this is where we apply opacity to the arrow
  4. $(window).scroll( function(){
  5.  
  6. //get scroll position
  7. var topWindow = $(window).scrollTop();
  8. //multipl by 1.5 so the arrow will become transparent half-way up the page
  9. var topWindow = topWindow * 1.5;
  10.  
  11. //get height of window
  12. var windowHeight = $(window).height();
  13.  
  14. //set position as percentage of how far the user has scrolled
  15. var position = topWindow / windowHeight;
  16. //invert the percentage
  17. position = 1 - position;
  18.  
  19. //define arrow opacity as based on how far up the page the user has scrolled
  20. //no scrolling = 1, half-way up the page = 0
  21. $('.arrow-wrap').css('opacity', position);
  22.  
  23. });
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. //Code stolen from css-tricks for smooth scrolling:
  31. $(function() {
  32. $('a[href*=#]:not([href=#])').click(function() {
  33. if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
  34. var target = $(this.hash);
  35. target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
  36. if (target.length) {
  37. $('html,body').animate({
  38. scrollTop: target.offset().top
  39. }, 1000);
  40. return false;
  41. }
  42. }
  43. });
  44.  
  45. });
  46. </script>
  47.  
  48. <a class="arrow-wrap" href="#tmp_customjs-95614">
  49. <span class="arrow"></span>
  50. <!--<span class="hint">scroll</span>-->
  51. </a>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement