Skip to content

Instantly share code, notes, and snippets.

@IgorGavrilenko
Created March 5, 2021 11:28
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 IgorGavrilenko/9fe4b27d5a5fef489ce778b9d34cf475 to your computer and use it in GitHub Desktop.
Save IgorGavrilenko/9fe4b27d5a5fef489ce778b9d34cf475 to your computer and use it in GitHub Desktop.
scroll detect
$.fn.hasScrollBar = function() {
return this.get(0).scrollWidth > this.width();
}
function wrapScroll() {
$('.wrap').each(function () {
if ($(this).hasScrollBar()) {
$(this).addClass('is-scroll');
} else {
$(this).removeClass('is-scroll');
}
});
};
wrapScroll();
$(document).on('change', function () {
wrapScroll();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment