Created
March 5, 2021 11:28
-
-
Save IgorGavrilenko/9fe4b27d5a5fef489ce778b9d34cf475 to your computer and use it in GitHub Desktop.
scroll detect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$.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