Advertisement
Guest User

Untitled

a guest
Oct 16th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. jQuery.fn.isOnScreen = function(){
  2.  var win = jQuery(window);
  3.  var viewport = {
  4.   top : win.scrollTop(),
  5.   left : win.scrollLeft()
  6.  };
  7.  viewport.right = viewport.left + win.width();
  8.  viewport.bottom = viewport.top + win.height();
  9.  var bounds = this.offset();
  10.  bounds.right = bounds.left + this.outerWidth();
  11.  bounds.bottom = bounds.top + this.outerHeight();
  12.  return (!(viewport.right < bounds.left || viewport.left > bounds.right || viewport.bottom < bounds.top || viewport.top > bounds.bottom));
  13. };
  14.  
  15.  
  16.  
  17. jQuery(window).scroll(function() {
  18. if(!jQuery('#section_one').isOnScreen()){
  19. $('#header-logo').height(0);
  20. $('#header-menu').height(60).width(60);
  21. $('header').css("background-color", "rgb(41, 41, 41, 0.2)");
  22. }else{
  23. $('#header-logo').height(204)
  24. $('#header-menu').height(50).width(50);
  25. $('header').css("background-color", "rgb(41, 41, 41, 1)");
  26. }
  27. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement