mirror of
https://github.com/thelounge/thelounge
synced 2024-11-23 04:23:13 +00:00
Merge pull request #2166 from dgw/2062-scroll-to-new-channels
Scroll to joined/activated channel
This commit is contained in:
commit
f105a11cd4
3 changed files with 11 additions and 1 deletions
|
@ -375,6 +375,7 @@ $(function() {
|
|||
utils.toggleNotificationMarkers(false);
|
||||
}
|
||||
|
||||
utils.scrollIntoViewNicely(self[0]);
|
||||
slideoutMenu.toggle(false);
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ const fuzzy = require("fuzzy");
|
|||
const Mousetrap = require("mousetrap");
|
||||
|
||||
const templates = require("../views");
|
||||
const utils = require("./utils");
|
||||
|
||||
const chat = $("#chat");
|
||||
|
||||
|
@ -93,7 +94,7 @@ exports.handleKeybinds = function(input) {
|
|||
}
|
||||
|
||||
// Adjust scroll when active item is outside of the visible area
|
||||
userlist.find(".user.active")[0].scrollIntoView(false);
|
||||
utils.scrollIntoViewNicely(userlist.find(".user.active")[0]);
|
||||
});
|
||||
|
||||
// When pressing Enter, open the context menu (emit a click) on the active
|
||||
|
|
|
@ -15,6 +15,7 @@ module.exports = {
|
|||
lastMessageId,
|
||||
confirmExit,
|
||||
forceFocus,
|
||||
scrollIntoViewNicely,
|
||||
hasRoleInChannel,
|
||||
move,
|
||||
resetHeight,
|
||||
|
@ -59,6 +60,13 @@ function forceFocus() {
|
|||
input.trigger("click").trigger("focus");
|
||||
}
|
||||
|
||||
// Reusable scrollIntoView parameters for channel list / user list
|
||||
function scrollIntoViewNicely(el) {
|
||||
// Ideally this would use behavior: "smooth", but that does not consistently work in e.g. Chrome
|
||||
// https://github.com/iamdustan/smoothscroll/issues/28#issuecomment-364061459
|
||||
el.scrollIntoView({block: "nearest", inline: "nearest"});
|
||||
}
|
||||
|
||||
function collapse() {
|
||||
$(".chan.active .toggle-button.toggle-preview.opened").click();
|
||||
return true;
|
||||
|
|
Loading…
Reference in a new issue