File tree Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Expand file tree Collapse file tree 1 file changed +8
-2
lines changed Original file line number Diff line number Diff line change @@ -24,6 +24,7 @@ if (process.env.NODE_ENV === 'production') {
2424 window . addEventListener ( 'load' , ( ) => listen ( ) ) ;
2525}
2626
27+ let raf = null ;
2728let title = document . querySelector ( 'h1' ) ;
2829
2930// Size the title to fit the available space.
@@ -45,7 +46,7 @@ function updateTitleFontSize() {
4546 }
4647
4748 // Reduce the font size until it doesn't overflow.
48- while ( title . scrollWidth > title . clientWidth ) {
49+ while ( fontSize > 10 && title . scrollWidth > title . clientWidth + 1 ) {
4950 fontSize -- ;
5051 title . style . fontSize = fontSize + 'px' ;
5152 }
@@ -56,8 +57,13 @@ updateTitleFontSize();
5657// Use ResizeObserver where available to detect size changes not related to window resizing, e.g. font loading.
5758if ( typeof ResizeObserver !== 'undefined' ) {
5859 let observer = new ResizeObserver ( ( ) => {
60+ if ( ! raf ) {
5961 // Avoid updating the layout during the resize event and creating circular notifications.
60- requestAnimationFrame ( updateTitleFontSize ) ;
62+ raf = requestAnimationFrame ( ( ) => {
63+ updateTitleFontSize ( ) ;
64+ raf = null ;
65+ } ) ;
66+ }
6167 } ) ;
6268 observer . observe ( title ) ;
6369} else {
You can’t perform that action at this time.
0 commit comments