Skip to content

Instantly share code, notes, and snippets.

@bryanrsebastian
Created December 17, 2020 06:09
Show Gist options
  • Save bryanrsebastian/3625f70ef70eabd7c9dc54c7655525e3 to your computer and use it in GitHub Desktop.
Save bryanrsebastian/3625f70ef70eabd7c9dc54c7655525e3 to your computer and use it in GitHub Desktop.
Use debounce function to make the resize event more optimized
var titleHeight = debounce( () => { //active the function every 250ms to improve website performance
var maxTitleHeight = Math.max.apply( null, $( '.__tag .__details h3' ).map( function () {
return $( this ).height();
} ).get() );
if( window.innerWidth > 548 ) {
$( '.__tag .__details h3' ).height( maxTitleHeight );
} else {
$( '.__tag .__details h3' ).height( 'auto' );
}
}, 250);
titleHeight();
window.addEventListener( 'resize', titleHeight );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment