To disable the shrink effect go to Customizer – Main menu and set same spacing for “Floating header” and “Static header”. You do not need custom code for this.
Note: To correct logo/title spacing go to Customizer – Site identity – Title and logo height (static and floating header)