Created
December 17, 2020 06:09
-
-
Save bryanrsebastian/3625f70ef70eabd7c9dc54c7655525e3 to your computer and use it in GitHub Desktop.
Use debounce function to make the resize event more optimized
This file contains hidden or 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
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