Advertisement
Guest User

Untitled

a guest
Jul 24th, 2019
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.41 KB | None | 0 0
  1. $(document).ready(function () {
  2. //Opens navigation bar for mobile if the button is clicked.
  3. $("#navigation-btn").on("click", function (event) {
  4. $("#mobile-navigation").addClass("visible");
  5. $("#navigation-btn").addClass("hidden");
  6. $("#navigation-btn").removeClass("visible");
  7. $("#mobile-navigation").removeClass("hidden");
  8. //Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event.
  9. //Navigation bar does not closes after opening.
  10. event.stopPropagation();
  11. });
  12. //Closes the navigation bar for mobile if the user clicks outside of the menu.
  13. $(document).on("click", function () {
  14. $("#mobile-navigation").addClass("hidden");
  15. $("#navigation-btn").addClass("visible");
  16. $("#navigation-btn").removeClass("hidden");
  17. $("#mobile-navigation").removeClass("visible");
  18. });
  19.  
  20. //Mouse particles
  21. $(document).mousemove(function (event) {
  22. //event gets mouse coordinates
  23. $("body").append(`<div class="particle" style="border-radius: 100%;position: fixed; top: ${event.pageY - $(window).scrollTop()}px; left: ${event.pageX}px; z-index: -1; background-color: #673ab7; width: 10px; height: 10px;"></div>`);
  24. $(".particle").fadeOut(200);
  25. setTimeout(function(){
  26. $(".particle").first().remove()
  27. }, 500);
  28. });
  29.  
  30. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement