cferdinandi/smooth-scroll

[feature] Mutation Observer on header element

strarsis opened this issue · 4 comments

It would be cool if smooth-scroll could use a MutationObserver on the header element so it can adjust the scroll offset when that header element changes (which can quite often happen by media queries).

This is a cool idea. I think at the very least, I should calculate the header height in real time as I'm about to scroll instead of caching that when the script is initiated.

MutationObserver adds a bit more weight, doesn't have the deep backwards compatibility the script currently enjoys, and doesn't have a great polyfill option.

(I understand this isn't exactly what you asked for, but I hope it gets you 99% there with better performance and easier script maintenance).

@cferdinandi: Awesome! When will there be a next release so
I can install smooth-scroll with these changes?

A MutationObserver would make more sense with your other project gumshoe
(which I also heavily use), because updating the dimensions (of selectorHeader) during
scrolling or using polling would be too performance consuming.