Skip to content
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

Restore stickiness of the menu bar #188

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions script/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,20 @@ window.Prosemirror.enableProsemirror = function enableProsemirror() {
nodeViews: getNodeViews(),
});
window.view = view;

// sticky menubar
jQuery(window).on('scroll.prosemirror_menu', () => {
const $container = jQuery('#prosemirror__editor');
const $menuBar = $container.find('.menubar');
const docViewTop = jQuery(window).scrollTop();
const containerTop = $container.offset().top;

if (docViewTop > containerTop) {
$menuBar.css('position', 'fixed');
} else {
$menuBar.css('position', '');
}
});
};

window.Prosemirror.destroyProsemirror = function destroyProsemirror() {
Expand Down
2 changes: 0 additions & 2 deletions style.less
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,6 @@
display: block;

.menubar {
position: sticky;
top: 0; // Users/Theme developers can override this to stick it below a sticky header
margin-bottom: 0.5rem;
border: @border-style;
border-radius: @border-radius;
Expand Down