Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. (function ($) {
  2. $(function () {
  3.  
  4. $('.button-collapse').sideNav();
  5. $('.parallax').parallax();
  6.  
  7. $(document).ready(function () {
  8. $(".dropdown-button").dropdown();
  9. });
  10.  
  11. $('.dropdown-button').dropdown({
  12. inDuration: 300,
  13. outDuration: 225,
  14. constrain_width: false, // Does not change width of dropdown to that of the activator
  15. hover: true, // Activate on hover
  16. gutter: 0, // Spacing from edge
  17. belowOrigin: false, // Displays dropdown below the button
  18. alignment: 'left' // Displays dropdown with edge aligned to the left of button
  19. });
  20.  
  21.  
  22.  
  23.  
  24. function isElementInViewport(el) {
  25. var rect = el.getBoundingClientRect();
  26. return (
  27. rect.top >= 0 &&
  28. rect.left >= 0 &&
  29. rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) &&
  30. rect.right <= (window.innerWidth || document.documentElement.clientWidth)
  31. );
  32. }
  33.  
  34. var items = document.querySelectorAll(".timeline li");
  35.  
  36. // code for the isElementInViewport function
  37.  
  38.  
  39. function callbackFunc() {
  40. for (var i = 0; i < items.length; i++) {
  41. if (isElementInViewport(items[i])) {
  42. items[i].classList.add("in-view");
  43. }
  44. }
  45. }
  46.  
  47. window.addEventListener("load", callbackFunc);
  48. window.addEventListener("scroll", callbackFunc);
  49.  
  50. }); // end of document ready
  51.  
  52.  
  53. })(jQuery); // end of jQuery name space
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement