fixed-logo.ejs 1.0 KB

1234567891011121314151617181920212223242526272829
  1. <div id="logo" class="dropright">
  2. <button unselectable="on" class="logo-button noselect" type="button" id="dropdownMenuButton" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
  3. <img class="hide-if-sm" src="/images/james-logo-white.svg">
  4. </button>
  5. <div class="dropdown-menu" aria-labelledby="dropdownMenuButton">
  6. <a class="dropdown-item" href="/">Home</a>
  7. <a class="dropdown-item" href="/projects">Projects</a>
  8. <a class="dropdown-item" href="/blog">Blog</a>
  9. </div>
  10. </div>
  11. <script>
  12. var logo = document.getElementById('logo');
  13. var cover = document.getElementById('cover')
  14. var invertLogo = function(){
  15. console.log(window.scrollY + "/" + cover.clientHeight)
  16. if(window.scrollY >= cover.clientHeight) {
  17. logo.classList.add("invert");
  18. }
  19. else if(window.scrollY < cover.clientHeight) {
  20. logo.classList.remove("invert");
  21. }
  22. }
  23. invertLogo()
  24. window.onscroll = function(){
  25. invertLogo();
  26. };
  27. </script>