Skip to content

Instantly share code, notes, and snippets.

@mattiasghodsian
Last active April 28, 2023 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mattiasghodsian/fc7480fefb449e809b5189ceead040eb to your computer and use it in GitHub Desktop.
Save mattiasghodsian/fc7480fefb449e809b5189ceead040eb to your computer and use it in GitHub Desktop.
Get Window Width and Height on resize
/**
* Donate a cup of coffee: https://www.buymeacoffee.com/mattiasghodsian
* Donate Eth: 0xBBB96204E45D11C9799c6B12E6eE6F0d4A071Ef5
*/
$(window).resize(function () {
windowWidth = $(window).outerWidth();
windowHeight = $(window).height();
booking_height = $('#element').outerHeight();
scrollpos = $('.grid').height() + 85;
if (booking_height > windowHeight - 60) {
$('#element').addClass('unfixed');
} else {
$('#element').removeClass('unfixed');
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment