Skip to content

Commit

Permalink
Restore stickiness of the menu bar
Browse files Browse the repository at this point in the history
lost in c398821 because templates have conflicting overflow in CSS
  • Loading branch information
annda committed Aug 14, 2023
1 parent d291c55 commit fd27592
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
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

0 comments on commit fd27592

Please sign in to comment.