Adjust for scrolling shenanigans.
This commit is contained in:
parent
74f116bfac
commit
4665b837a0
3 changed files with 17 additions and 1 deletions
|
@ -38,7 +38,7 @@ const MamiEmotePicker = function(args) {
|
|||
$rc(listElem);
|
||||
|
||||
for(const emote of emotes)
|
||||
listElem.appendChild(<button class="emopick-emote" type="button" data-strings={emote.strings.join(' ')} onclick={() => {
|
||||
listElem.appendChild(<button class="emopick-emote" type="button" title={`:${emote.strings[0]}:`} data-strings={emote.strings.join(' ')} onclick={() => {
|
||||
args.onPick(emote);
|
||||
if(!keepOpenToggleElem.checked)
|
||||
close();
|
||||
|
|
|
@ -16,6 +16,7 @@ Umi.UI.InputMenus = (function() {
|
|||
|
||||
const buttonId = createButtonId(baseId);
|
||||
const menuId = 'umi-msg-menu-sub-' + baseId;
|
||||
const isScrolledToBottom = Umi.UI.Messages.IsScrolledToBottom();
|
||||
|
||||
const activeMenus = Array.from($qa(`.${inputMenuActive}`));
|
||||
if(activeMenus.length > 0)
|
||||
|
@ -34,6 +35,9 @@ Umi.UI.InputMenus = (function() {
|
|||
} else {
|
||||
current = '';
|
||||
}
|
||||
|
||||
if(isScrolledToBottom)
|
||||
Umi.UI.Messages.ScrollIfNeeded();
|
||||
};
|
||||
|
||||
const createButton = function(id, title, onClick) {
|
||||
|
|
|
@ -371,17 +371,29 @@ Umi.UI.Messages = (function() {
|
|||
|
||||
mami.globalEvents.dispatch('umi:ui:message_add', { element: eBase });
|
||||
},
|
||||
IsScrolledToBottom: () => {
|
||||
const msgsList = $i('umi-messages');
|
||||
return msgsList.scrollTop === (msgsList.scrollHeight - msgsList.offsetHeight);
|
||||
},
|
||||
ScrollIfNeeded: () => {
|
||||
if(mami.settings.get('autoScroll'))
|
||||
$i('umi-messages').lastElementChild?.scrollIntoView({ inline: 'end' });
|
||||
},
|
||||
SwitchChannel: channel => {
|
||||
if(typeof channel === 'object' && channel !== null && 'name' in channel)
|
||||
channel = channel.name;
|
||||
if(typeof channel !== 'string')
|
||||
return;
|
||||
|
||||
const isScrolledToBottom = Umi.UI.Messages.IsScrolledToBottom();
|
||||
focusChannelName = channel;
|
||||
|
||||
const root = $i('umi-messages');
|
||||
for(const elem of root.children)
|
||||
elem.classList.toggle('hidden', elem.dataset.channel !== undefined && elem.dataset.channel !== focusChannelName);
|
||||
|
||||
if(isScrolledToBottom)
|
||||
Umi.UI.Messages.ScrollIfNeeded();
|
||||
},
|
||||
Clear: retain => {
|
||||
if(typeof retain === 'string' && !isNaN(retain))
|
||||
|
|
Loading…
Reference in a new issue