-
Notifications
You must be signed in to change notification settings - Fork 77
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make menubar float work inside a scollable parent (not just window) #16
Conversation
Thanks for looking into this, and welcome. I can see a potential problem with an We could use I think there's also an issue when there are multiple scrolling parents (which might be made worse by my proposed change). Would it make sense to have an array of scrolling parents, rather than a single one? |
Those are good ideas. I started with I can take a crack at this soon. |
@marijnh how about this updated approach: just listen for scroll on all parents + window? Just adding/removing a listener for an event that never gets fired is cheap, and it makes this implementation quite simple and robust. It turns out for my use case I was both changing the size (as the user typed beyond 1 page) and changing the computed overflow-y (in a media query) but doing it this way makes it pretty unbreakable.. |
Thanks, that looks like a good idea. Could you update the name of the function that gets the parent nodes to reflect its current behavior? That's the last nitpick I have, I think. |
How about |
That works. Merged as 7f442f0, and released as 1.0.3. |
@cjbest - I'd like to make a change to the menubar so that I can pass a top offset. I'm not sure how your scrollAncestor change is supposed to work. In the demo example, the scrollAncestor is always undefined, and therefore, the top position of the menubar is never changed, i.e. this test in updateFloat() in menubar.js always fails: |
@jabbermarky the scrollAncestor gets set when the thing that is scrolling is not the whole document, but rather some other enclosing container. For example, lets say you want to have a top bar that's above the editor. You could make a two-pane flexbox layout, with the the bottom pane flexing and having |
Ah, I missed this new discussion before opening #18—but yeah, see my comment there. |
Say you put a prosemirror editor with a menubar inside of a scrollable div, and you still want that nice float + sticky behaviour.
Before, we wouldn't even catch the scroll events (they don't get fired on window.) With this change, we look for cases where we are in a scrollable element, catch those events too, and detect + float to the appropriate top location.
This is my first PR here, so I apologize in advance if I've made any faux pas.