Hide header when scrolling down


I added a directive to hide the header when scrolling down content using this answer: https://stackoverflow.com/questions/52744930/ionic-4-hide-toolbar-on-scroll/54109730#54109730

but the header keeps flickering when scrolling too fast like in this video I made for this: https://voicer.com/uploads/yFsEo/1573571488Ionic-header-flickering-on-scroll-down.mp4

Does anyone know how to help?
And is there any official directive for hiding the header / footer when scrolling content?

may be this will help