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);
|
$rc(listElem);
|
||||||
|
|
||||||
for(const emote of emotes)
|
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);
|
args.onPick(emote);
|
||||||
if(!keepOpenToggleElem.checked)
|
if(!keepOpenToggleElem.checked)
|
||||||
close();
|
close();
|
||||||
|
|
|
@ -16,6 +16,7 @@ Umi.UI.InputMenus = (function() {
|
||||||
|
|
||||||
const buttonId = createButtonId(baseId);
|
const buttonId = createButtonId(baseId);
|
||||||
const menuId = 'umi-msg-menu-sub-' + baseId;
|
const menuId = 'umi-msg-menu-sub-' + baseId;
|
||||||
|
const isScrolledToBottom = Umi.UI.Messages.IsScrolledToBottom();
|
||||||
|
|
||||||
const activeMenus = Array.from($qa(`.${inputMenuActive}`));
|
const activeMenus = Array.from($qa(`.${inputMenuActive}`));
|
||||||
if(activeMenus.length > 0)
|
if(activeMenus.length > 0)
|
||||||
|
@ -34,6 +35,9 @@ Umi.UI.InputMenus = (function() {
|
||||||
} else {
|
} else {
|
||||||
current = '';
|
current = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(isScrolledToBottom)
|
||||||
|
Umi.UI.Messages.ScrollIfNeeded();
|
||||||
};
|
};
|
||||||
|
|
||||||
const createButton = function(id, title, onClick) {
|
const createButton = function(id, title, onClick) {
|
||||||
|
|
|
@ -371,17 +371,29 @@ Umi.UI.Messages = (function() {
|
||||||
|
|
||||||
mami.globalEvents.dispatch('umi:ui:message_add', { element: eBase });
|
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 => {
|
SwitchChannel: channel => {
|
||||||
if(typeof channel === 'object' && channel !== null && 'name' in channel)
|
if(typeof channel === 'object' && channel !== null && 'name' in channel)
|
||||||
channel = channel.name;
|
channel = channel.name;
|
||||||
if(typeof channel !== 'string')
|
if(typeof channel !== 'string')
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const isScrolledToBottom = Umi.UI.Messages.IsScrolledToBottom();
|
||||||
focusChannelName = channel;
|
focusChannelName = channel;
|
||||||
|
|
||||||
const root = $i('umi-messages');
|
const root = $i('umi-messages');
|
||||||
for(const elem of root.children)
|
for(const elem of root.children)
|
||||||
elem.classList.toggle('hidden', elem.dataset.channel !== undefined && elem.dataset.channel !== focusChannelName);
|
elem.classList.toggle('hidden', elem.dataset.channel !== undefined && elem.dataset.channel !== focusChannelName);
|
||||||
|
|
||||||
|
if(isScrolledToBottom)
|
||||||
|
Umi.UI.Messages.ScrollIfNeeded();
|
||||||
},
|
},
|
||||||
Clear: retain => {
|
Clear: retain => {
|
||||||
if(typeof retain === 'string' && !isNaN(retain))
|
if(typeof retain === 'string' && !isNaN(retain))
|
||||||
|
|
Loading…
Reference in a new issue