mirror of
https://github.com/scinote-eln/scinote-web.git
synced 2025-01-08 00:23:01 +08:00
Reposition comment dropdowns horizontally if needed
Closes SCI-258
This commit is contained in:
parent
4ee4c6caba
commit
77ec5bcff9
1 changed files with 14 additions and 0 deletions
|
@ -1,6 +1,20 @@
|
|||
function initCommentOptions(scrollableContainer, useParentOffset = true) {
|
||||
scrollCommentOptions($(".dropdown-comment"), useParentOffset);
|
||||
|
||||
// Reposition dropdown to the left
|
||||
// (only do this when using parent offset)
|
||||
if (useParentOffset) {
|
||||
$(document).on("shown.bs.dropdown", ".dropdown-comment", function() {
|
||||
var $el = $(this);
|
||||
var menu = $el.find(".dropdown-menu");
|
||||
var leftPos = $el.offset().left;
|
||||
if (leftPos + menu.width() > $(window).width()) {
|
||||
menu.offset({ left: leftPos - menu.width() });
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Reposition dropdowns vertically on scroll events
|
||||
document.addEventListener('scroll', function (event) {
|
||||
var $target = $(event.target);
|
||||
var parent = $(scrollableContainer);
|
||||
|
|
Loading…
Reference in a new issue