UI performance fixes (#3207) * Optimize visibility checks for burger and wand menus * Optimize message actions visibility toggle * Run drawer toggle in animation frame * Replace jQuery slideToggle with a 3rd-party lib * Refactor export button functionality to manage popup state with a boolean flag * Do not close the pinned drawer on unpin * Revert "Do not close the pinned drawer on unpin" This reverts commit e3b34e9a586db853dd84809f4187d5b29cb9ac36. * Refactor slideToggle options * ease-in-out * Don't skip frame on drawer toggle
Signed| @@ -63,6 +63,7 @@ | ||
| 63 | 63 | "showdown": "^2.1.0", |
| 64 | 64 | "sillytavern-transformers": "2.14.6", |
| 65 | 65 | "simple-git": "^3.19.1", |
| 66 | + "slidetoggle": "^4.0.0", | |
| 66 | 67 | "tiktoken": "^1.0.16", |
| 67 | 68 | "vectra": "^0.2.2", |
| 68 | 69 | "wavefile": "^11.0.0", |
| @@ -6531,6 +6532,12 @@ | ||
| 6531 | 6532 | "integrity": "sha512-VZBmZP8WU3sMOZm1bdgTadsQbcscK0UM8oKxKVBs4XAhUo2Xxzm/OFMGBkPusxw9xL3Uy8LrzEqGqJhclsr0yA==", |
| 6532 | 6533 | "license": "MIT" |
| 6533 | 6534 | }, |
| 6535 | + "node_modules/slidetoggle": { | |
| 6536 | + "version": "4.0.0", | |
| 6537 | + "resolved": "https://registry.npmjs.org/slidetoggle/-/slidetoggle-4.0.0.tgz", | |
| 6538 | + "integrity": "sha512-6qvrOS1dnDFEr41UEEFFRQE8nswaAFIYZAHer6dVlznRIjHyCISjNJoxIn5U5QlAbZfBBxTELQk4jS7miHto1A==", | |
| 6539 | + "license": "MIT" | |
| 6540 | + }, | |
| 6534 | 6541 | "node_modules/smart-buffer": { |
| 6535 | 6542 | "version": "4.2.0", |
| 6536 | 6543 | "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", |
| @@ -53,6 +53,7 @@ | ||
| 53 | 53 | "showdown": "^2.1.0", |
| 54 | 54 | "sillytavern-transformers": "2.14.6", |
| 55 | 55 | "simple-git": "^3.19.1", |
| 56 | + "slidetoggle": "^4.0.0", | |
| 56 | 57 | "tiktoken": "^1.0.16", |
| 57 | 58 | "vectra": "^0.2.2", |
| 58 | 59 | "wavefile": "^11.0.0", |
| @@ -19,6 +19,7 @@ import seedrandom from 'seedrandom'; | ||
| 19 | 19 | import * as Popper from '@popperjs/core'; |
| 20 | 20 | import droll from 'droll'; |
| 21 | 21 | import morphdom from 'morphdom'; |
| 22 | +import { toggle as slideToggle } from 'slidetoggle'; | |
| 22 | 23 | |
| 23 | 24 | /** |
| 24 | 25 | * Expose the libraries to the 'window' object. |
| @@ -94,6 +95,7 @@ export default { | ||
| 94 | 95 | Popper, |
| 95 | 96 | droll, |
| 96 | 97 | morphdom, |
| 98 | + slideToggle, | |
| 97 | 99 | }; |
| 98 | 100 | |
| 99 | 101 | export { |
| @@ -115,4 +117,5 @@ export { | ||
| 115 | 117 | Popper, |
| 116 | 118 | droll, |
| 117 | 119 | morphdom, |
| 120 | + slideToggle, | |
| 118 | 121 | }; |
| @@ -10,6 +10,7 @@ import { | ||
| 10 | 10 | SVGInject, |
| 11 | 11 | Popper, |
| 12 | 12 | initLibraryShims, |
| 13 | + slideToggle, | |
| 13 | 14 | default as libs, |
| 14 | 15 | } from './lib.js'; |
| 15 | 16 | |
| @@ -549,6 +550,7 @@ let optionsPopper = Popper.createPopper(document.getElementById('options_button' | ||
| 549 | 550 | let exportPopper = Popper.createPopper(document.getElementById('export_button'), document.getElementById('export_format_popup'), { |
| 550 | 551 | placement: 'left', |
| 551 | 552 | }); |
| 553 | +let isExportPopupOpen = false; | |
| 552 | 554 | |
| 553 | 555 | // Saved here for performance reasons |
| 554 | 556 | const messageTemplate = $('#message_template .mes'); |
| @@ -895,6 +897,13 @@ export function getRequestHeaders() { | ||
| 895 | 897 | }; |
| 896 | 898 | } |
| 897 | 899 | |
| 900 | +export function getSlideToggleOptions() { | |
| 901 | + return { | |
| 902 | + miliseconds: animation_duration * 1.5, | |
| 903 | + transitionFunction: animation_duration > 0 ? 'ease-in-out' : 'step-start', | |
| 904 | + }; | |
| 905 | +} | |
| 906 | + | |
| 898 | 907 | $.ajaxPrefilter((options, originalOptions, xhr) => { |
| 899 | 908 | xhr.setRequestHeader('X-CSRF-Token', token); |
| 900 | 909 | }); |
| @@ -9209,40 +9218,48 @@ function doDrawerOpenClick() { | ||
| 9209 | 9218 | * @returns {void} |
| 9210 | 9219 | */ |
| 9211 | 9220 | function doNavbarIconClick() { |
| 9212 | 9221 | varconst icon = $(this).find('.drawer-icon'); |
| 9213 | 9222 | varconst drawer = $(this).parent().find('.drawer-content'); |
| 9214 | 9223 | if (drawer.hasClass('resizing')) { return; } |
| 9215 | 9224 | varconst drawerWasOpenAlready = $(this).parent().find('.drawer-content').hasClass('openDrawer'); |
| 9216 | 9225 | letconst targetDrawerID = $(this).parent().find('.drawer-content').attr('id'); |
| 9217 | 9226 | const pinnedDrawerClicked = drawer.hasClass('pinnedOpen'); |
| 9218 | 9227 | |
| 9219 | 9228 | if (!drawerWasOpenAlready) { //to open the drawer |
| 9220 | 9229 | $('.openDrawer').not('.pinnedOpen').addClass('resizing').slideToggleeach(200, 'swing'(_, async function (el) => { |
| 9221 | - await delay(50); $(this).closest('.drawer-content').removeClass('resizing'); | |
| 9230 | + slideToggle(el, { | |
| 9231 | + ...getSlideToggleOptions(), | |
| 9232 | + onAnimationEnd: function (el) { | |
| 9233 | + el.closest('.drawer-content').classList.remove('resizing'); | |
| 9234 | + }, | |
| 9235 | + }); | |
| 9222 | 9236 | }); |
| 9223 | 9237 | $('.openIcon').not('.drawerPinnedOpen').toggleClass('closedIcon openIcon'); |
| 9224 | 9238 | $('.openDrawer').not('.pinnedOpen').toggleClass('closedDrawer openDrawer'); |
| 9225 | 9239 | icon.toggleClass('openIcon closedIcon'); |
| 9226 | 9240 | drawer.toggleClass('openDrawer closedDrawer'); |
| 9227 | 9241 | |
| 9228 | 9242 | //console.log(targetDrawerID); |
| 9229 | 9243 | if (targetDrawerID === 'right-nav-panel') { |
| 9230 | 9244 | $(this).closest('.drawer').find('.drawer-content').addClass('resizing').slideToggleeach((_, el) => { |
| 9231 | - duration: 200, | |
| 9245 | + slideToggle(el, { | |
| 9232 | - easing: 'swing', | |
| 9246 | + ...getSlideToggleOptions(), | |
| 9233 | - start: function () { | |
| 9247 | + elementDisplayStyle: 'flex', | |
| 9234 | - jQuery(this).css('display', 'flex'); //flex needed to make charlist scroll | |
| 9248 | + onAnimationEnd: function (el) { | |
| 9235 | - }, | |
| 9249 | + el.closest('.drawer-content').classList.remove('resizing'); | |
| 9236 | - complete: async function () { | |
| 9237 | 9250 | favsToHotswap(); |
| 9238 | - await delay(50); | |
| 9239 | - $(this).closest('.drawer-content').removeClass('resizing'); | |
| 9240 | 9251 | $('#rm_print_characters_block').trigger('scroll'); |
| 9241 | 9252 | }, |
| 9242 | 9253 | }); |
| 9254 | + }); | |
| 9243 | 9255 | } else { |
| 9244 | 9256 | $(this).closest('.drawer').find('.drawer-content').addClass('resizing').slideToggleeach(200, 'swing'(_, async function (el) => { |
| 9245 | - await delay(50); $(this).closest('.drawer-content').removeClass('resizing'); | |
| 9257 | + slideToggle(el, { | |
| 9258 | + ...getSlideToggleOptions(), | |
| 9259 | + onAnimationEnd: function (el) { | |
| 9260 | + el.closest('.drawer-content').classList.remove('resizing'); | |
| 9261 | + }, | |
| 9262 | + }); | |
| 9246 | 9263 | }); |
| 9247 | 9264 | } |
| 9248 | 9265 | |
| @@ -9258,13 +9275,23 @@ function doNavbarIconClick() { | ||
| 9258 | 9275 | icon.toggleClass('closedIcon openIcon'); |
| 9259 | 9276 | |
| 9260 | 9277 | if (pinnedDrawerClicked) { |
| 9261 | 9278 | $(drawer).addClass('resizing').slideToggleeach(200, 'swing'(_, async function (el) => { |
| 9262 | - await delay(50); $(this).removeClass('resizing'); | |
| 9279 | + slideToggle(el, { | |
| 9280 | + ...getSlideToggleOptions(), | |
| 9281 | + onAnimationEnd: function (el) { | |
| 9282 | + el.classList.remove('resizing'); | |
| 9283 | + }, | |
| 9284 | + }); | |
| 9263 | 9285 | }); |
| 9264 | 9286 | } |
| 9265 | 9287 | else { |
| 9266 | 9288 | $('.openDrawer').not('.pinnedOpen').addClass('resizing').slideToggleeach(200, 'swing'(_, async function (el) => { |
| 9267 | - await delay(50); $(this).closest('.drawer-content').removeClass('resizing'); | |
| 9289 | + slideToggle(el, { | |
| 9290 | + ...getSlideToggleOptions(), | |
| 9291 | + onAnimationEnd: function (el) { | |
| 9292 | + el.closest('.drawer-content').classList.remove('resizing'); | |
| 9293 | + }, | |
| 9294 | + }); | |
| 9268 | 9295 | }); |
| 9269 | 9296 | } |
| 9270 | 9297 | |
| @@ -10086,20 +10113,21 @@ jQuery(async function () { | ||
| 10086 | 10113 | await getStatusNovel(); |
| 10087 | 10114 | }); |
| 10088 | 10115 | |
| 10089 | 10116 | varconst button = $('#options_button'); |
| 10090 | 10117 | varconst menu = $('#options'); |
| 10118 | + let isOptionsMenuVisible = false; | |
| 10091 | 10119 | |
| 10092 | 10120 | function showMenu() { |
| 10093 | 10121 | showBookmarksButtons(); |
| 10094 | - // menu.stop() | |
| 10095 | 10122 | menu.fadeIn(animation_duration); |
| 10096 | 10123 | optionsPopper.update(); |
| 10124 | + isOptionsMenuVisible = true; | |
| 10097 | 10125 | } |
| 10098 | 10126 | |
| 10099 | 10127 | function hideMenu() { |
| 10100 | - // menu.stop(); | |
| 10101 | 10128 | menu.fadeOut(animation_duration); |
| 10102 | 10129 | optionsPopper.update(); |
| 10130 | + isOptionsMenuVisible = false; | |
| 10103 | 10131 | } |
| 10104 | 10132 | |
| 10105 | 10133 | function isMouseOverButtonOrMenu() { |
| @@ -10107,26 +10135,15 @@ jQuery(async function () { | ||
| 10107 | 10135 | } |
| 10108 | 10136 | |
| 10109 | 10137 | button.on('click', function () { |
| 10110 | 10138 | if (menu.is(':visible')isOptionsMenuVisible) { |
| 10111 | 10139 | hideMenu(); |
| 10112 | 10140 | } else { |
| 10113 | 10141 | showMenu(); |
| 10114 | 10142 | } |
| 10115 | 10143 | }); |
| 10116 | - button.on('blur', function () { | |
| 10117 | - //delay to prevent menu hiding when mouse leaves button into menu | |
| 10118 | - setTimeout(() => { | |
| 10119 | - if (!isMouseOverButtonOrMenu()) { hideMenu(); } | |
| 10120 | - }, 100); | |
| 10121 | - }); | |
| 10122 | - menu.on('blur', function () { | |
| 10123 | - //delay to prevent menu hide when mouseleaves menu into button | |
| 10124 | - setTimeout(() => { | |
| 10125 | - if (!isMouseOverButtonOrMenu()) { hideMenu(); } | |
| 10126 | - }, 100); | |
| 10127 | - }); | |
| 10128 | 10144 | $(document).on('click', function () { |
| 10129 | - if (!isMouseOverButtonOrMenu() && menu.is(':visible')) { hideMenu(); } | |
| 10145 | + if (!isOptionsMenuVisible) return; | |
| 10146 | + if (!isMouseOverButtonOrMenu()) { hideMenu(); } | |
| 10130 | 10147 | }); |
| 10131 | 10148 | |
| 10132 | 10149 | /* $('#set_chat_scenario').on('click', setScenarioOverride); */ |
| @@ -10522,22 +10539,28 @@ jQuery(async function () { | ||
| 10522 | 10539 | }); |
| 10523 | 10540 | |
| 10524 | 10541 | $(document).on('click', '.extraMesButtonsHint', function (e) { |
| 10525 | 10542 | const elmnt$hint = $(e.target); |
| 10526 | - $(elmnt).transition({ | |
| 10543 | + const $buttons = $hint.siblings('.extraMesButtons'); | |
| 10544 | + | |
| 10545 | + $hint.transition({ | |
| 10527 | 10546 | opacity: 0, |
| 10528 | 10547 | duration: animation_duration, |
| 10529 | 10548 | easing: 'ease-in-out'animation_easing, |
| 10530 | - }); | |
| 10549 | + complete: function () { | |
| 10531 | - setTimeout(function () { | |
| 10550 | + $hint.hide(); | |
| 10532 | - $(elmnt).hide(); | |
| 10551 | + $buttons | |
| 10533 | - $(elmnt).siblings('.extraMesButtons').css('opcacity', '0'); | |
| 10552 | + .addClass('visible') | |
| 10534 | - $(elmnt).siblings('.extraMesButtons').css('display', 'flex'); | |
| 10553 | + .css({ | |
| 10535 | - $(elmnt).siblings('.extraMesButtons').transition({ | |
| 10554 | + opacity: 0, | |
| 10555 | + display: 'flex', | |
| 10556 | + }) | |
| 10557 | + .transition({ | |
| 10536 | 10558 | opacity: 1, |
| 10537 | 10559 | duration: animation_duration, |
| 10538 | - easing: 'ease-in-out', | |
| 10560 | + easing: animation_easing, | |
| 10561 | + }); | |
| 10562 | + }, | |
| 10539 | 10563 | }); |
| 10540 | - }, animation_duration); | |
| 10541 | 10564 | }); |
| 10542 | 10565 | |
| 10543 | 10566 | $(document).on('click', function (e) { |
| @@ -10548,19 +10571,32 @@ jQuery(async function () { | ||
| 10548 | 10571 | |
| 10549 | 10572 | // Check if the click was outside the relevant elements |
| 10550 | 10573 | if (!$(e.target).closest('.extraMesButtons, .extraMesButtonsHint').length) { |
| 10574 | + const $visibleButtons = $('.extraMesButtons.visible'); | |
| 10575 | + | |
| 10576 | + if (!$visibleButtons.length) { | |
| 10577 | + return; | |
| 10578 | + } | |
| 10579 | + | |
| 10580 | + const $hiddenHints = $('.extraMesButtonsHint:hidden'); | |
| 10581 | + | |
| 10551 | 10582 | // Transition out the .extraMesButtons first |
| 10552 | 10583 | $('.extraMesButtons:visible')visibleButtons.transition({ |
| 10553 | 10584 | opacity: 0, |
| 10554 | 10585 | duration: animation_duration, |
| 10555 | 10586 | easing: 'ease-in-out'animation_easing, |
| 10556 | 10587 | complete: function () { |
| 10557 | 10588 | $(this).hide(); // Hide the .extraMesButtons after the transition |
| 10589 | + $(this) | |
| 10590 | + .hide() | |
| 10591 | + .removeClass('visible'); | |
| 10558 | 10592 | |
| 10559 | 10593 | // Transition the .extraMesButtonsHint back in |
| 10560 | - $('.extraMesButtonsHint:not(:visible)').show().transition({ | |
| 10594 | + $hiddenHints | |
| 10561 | - opacity: .3, | |
| 10595 | + .show() | |
| 10596 | + .transition({ | |
| 10597 | + opacity: 0.3, | |
| 10562 | 10598 | duration: animation_duration, |
| 10563 | - easing: 'ease-in-out', | |
| 10599 | + easing: animation_easing, | |
| 10564 | 10600 | complete: function () { |
| 10565 | 10601 | $(this).css('opacity', ''); |
| 10566 | 10602 | }, |
| @@ -10748,8 +10784,9 @@ jQuery(async function () { | ||
| 10748 | 10784 | } |
| 10749 | 10785 | }); |
| 10750 | 10786 | |
| 10751 | 10787 | $('#export_button').on('click', function (e) { |
| 10752 | - $('#export_format_popup').toggle(); | |
| 10788 | + isExportPopupOpen = !isExportPopupOpen; | |
| 10789 | + $('#export_format_popup').toggle(isExportPopupOpen); | |
| 10753 | 10790 | exportPopper.update(); |
| 10754 | 10791 | }); |
| 10755 | 10792 | |
| @@ -10760,6 +10797,10 @@ jQuery(async function () { | ||
| 10760 | 10797 | return; |
| 10761 | 10798 | } |
| 10762 | 10799 | |
| 10800 | + $('#export_format_popup').hide(); | |
| 10801 | + isExportPopupOpen = false; | |
| 10802 | + exportPopper.update(); | |
| 10803 | + | |
| 10763 | 10804 | // Save before exporting |
| 10764 | 10805 | await createOrEditCharacter(); |
| 10765 | 10806 | const body = { format, avatar_url: characters[this_chid].avatar }; |
| @@ -10781,9 +10822,6 @@ jQuery(async function () { | ||
| 10781 | 10822 | URL.revokeObjectURL(a.href); |
| 10782 | 10823 | document.body.removeChild(a); |
| 10783 | 10824 | } |
| 10784 | - | |
| 10785 | - | |
| 10786 | - $('#export_format_popup').hide(); | |
| 10787 | 10825 | }); |
| 10788 | 10826 | //**************************CHAT IMPORT EXPORT*************************// |
| 10789 | 10827 | $('#chat_import_button').click(function () { |
| @@ -10855,15 +10893,18 @@ jQuery(async function () { | ||
| 10855 | 10893 | }); |
| 10856 | 10894 | |
| 10857 | 10895 | $(document).on('click', '.drawer-opener', doDrawerOpenClick); |
| 10896 | + | |
| 10858 | 10897 | $('.drawer-toggle').on('click', doNavbarIconClick); |
| 10859 | 10898 | |
| 10860 | 10899 | $('html').on('touchstart mousedown', function (e) { |
| 10861 | 10900 | var clickTarget = $(e.target); |
| 10862 | 10901 | |
| 10863 | - if ($('#export_format_popup').is(':visible') | |
| 10902 | + if (isExportPopupOpen | |
| 10864 | 10903 | && clickTarget.closest('#export_button').length == 0 |
| 10865 | 10904 | && clickTarget.closest('#export_format_popup').length == 0) { |
| 10866 | 10905 | $('#export_format_popup').hide(); |
| 10906 | + isExportPopupOpen = false; | |
| 10907 | + exportPopper.update(); | |
| 10867 | 10908 | } |
| 10868 | 10909 | |
| 10869 | 10910 | const forbiddenTargets = [ |
| @@ -10888,12 +10929,16 @@ jQuery(async function () { | ||
| 10888 | 10929 | if ($('.openDrawer').length !== 0) { |
| 10889 | 10930 | if (targetParentHasOpenDrawer === 0) { |
| 10890 | 10931 | //console.log($('.openDrawer').not('.pinnedOpen').length); |
| 10891 | 10932 | $('.openDrawer').not('.pinnedOpen').addClass('resizing').slideToggleeach(200, 'swing'(_, function (el) => { |
| 10892 | - $(this).closest('.drawer-content').removeClass('resizing'); | |
| 10933 | + slideToggle(el, { | |
| 10934 | + ...getSlideToggleOptions(), | |
| 10935 | + onAnimationEnd: (el) => { | |
| 10936 | + el.closest('.drawer-content').classList.remove('resizing'); | |
| 10937 | + }, | |
| 10938 | + }); | |
| 10893 | 10939 | }); |
| 10894 | 10940 | $('.openIcon').not('.drawerPinnedOpen').toggleClass('closedIcon openIcon'); |
| 10895 | 10941 | $('.openDrawer').not('.pinnedOpen').toggleClass('closedDrawer openDrawer'); |
| 10896 | - | |
| 10897 | 10942 | } |
| 10898 | 10943 | } |
| 10899 | 10944 | } |
| @@ -11059,14 +11104,6 @@ jQuery(async function () { | ||
| 11059 | 11104 | case 'renameCharButton': |
| 11060 | 11105 | renameCharacter(); |
| 11061 | 11106 | break; |
| 11062 | - /*case 'dupe_button': | |
| 11063 | - DupeChar(); | |
| 11064 | - break; | |
| 11065 | - case 'export_button': | |
| 11066 | - $('#export_format_popup').toggle(); | |
| 11067 | - exportPopper.update(); | |
| 11068 | - break; | |
| 11069 | - */ | |
| 11070 | 11107 | case 'import_character_info': |
| 11071 | 11108 | await importEmbeddedWorldInfo(); |
| 11072 | 11109 | saveCharacterDebounced(); |
| @@ -1,4 +1,4 @@ | ||
| 1 | 1 | import { DOMPurify, Bowser, slideToggle } from '../lib.js'; |
| 2 | 2 | |
| 3 | 3 | import { |
| 4 | 4 | characters, |
| @@ -19,6 +19,7 @@ import { | ||
| 19 | 19 | menu_type, |
| 20 | 20 | substituteParams, |
| 21 | 21 | sendTextareaMessage, |
| 22 | + getSlideToggleOptions, | |
| 22 | 23 | } from '../script.js'; |
| 23 | 24 | |
| 24 | 25 | import { |
| @@ -748,8 +749,8 @@ export function initRossMods() { | ||
| 748 | 749 | $(RightNavDrawerIcon).removeClass('drawerPinnedOpen'); |
| 749 | 750 | |
| 750 | 751 | if ($(RightNavPanel).hasClass('openDrawer') && $('.openDrawer').length > 1) { |
| 751 | 752 | $(RightNavPanel).slideToggle(200RightNavPanel, 'swing'getSlideToggleOptions()); |
| 752 | 753 | $(RightNavDrawerIcon).toggleClass('openIcon closedIcon openIcon'); |
| 753 | 754 | $(RightNavPanel).toggleClass('openDrawer closedDrawer'); |
| 754 | 755 | } |
| 755 | 756 | } |
| @@ -766,8 +767,8 @@ export function initRossMods() { | ||
| 766 | 767 | $(LeftNavDrawerIcon).removeClass('drawerPinnedOpen'); |
| 767 | 768 | |
| 768 | 769 | if ($(LeftNavPanel).hasClass('openDrawer') && $('.openDrawer').length > 1) { |
| 769 | 770 | $(LeftNavPanel).slideToggle(200LeftNavPanel, 'swing'getSlideToggleOptions()); |
| 770 | 771 | $(LeftNavDrawerIcon).toggleClass('openIcon closedIcon openIcon'); |
| 771 | 772 | $(LeftNavPanel).toggleClass('openDrawer closedDrawer'); |
| 772 | 773 | } |
| 773 | 774 | } |
| @@ -786,8 +787,8 @@ export function initRossMods() { | ||
| 786 | 787 | |
| 787 | 788 | if ($(WorldInfo).hasClass('openDrawer') && $('.openDrawer').length > 1) { |
| 788 | 789 | console.debug('closing WI after lock removal'); |
| 789 | 790 | $(WorldInfo).slideToggle(200WorldInfo, 'swing'getSlideToggleOptions()); |
| 790 | 791 | $(WIDrawerIcon).toggleClass('openIcon closedIcon openIcon'); |
| 791 | 792 | $(WorldInfo).toggleClass('openDrawer closedDrawer'); |
| 792 | 793 | } |
| 793 | 794 | } |
| @@ -417,26 +417,30 @@ async function addExtensionsButtonAndMenu() { | ||
| 417 | 417 | |
| 418 | 418 | const button = $('#extensionsMenuButton'); |
| 419 | 419 | const dropdown = $('#extensionsMenu'); |
| 420 | - //dropdown.hide(); | |
| 420 | + let isDropdownVisible = false; | |
| 421 | 421 | |
| 422 | 422 | let popper = Popper.createPopper(button.get(0), dropdown.get(0), { |
| 423 | 423 | placement: 'top-start', |
| 424 | 424 | }); |
| 425 | 425 | |
| 426 | 426 | $(button).on('click', function () { |
| 427 | 427 | if (dropdown.is(':visible')isDropdownVisible) { |
| 428 | 428 | dropdown.fadeOut(animation_duration); |
| 429 | + isDropdownVisible = false; | |
| 429 | 430 | } else { |
| 430 | 431 | dropdown.fadeIn(animation_duration); |
| 432 | + isDropdownVisible = true; | |
| 431 | 433 | } |
| 432 | 434 | popper.update(); |
| 433 | 435 | }); |
| 434 | 436 | |
| 435 | 437 | $('html').on('click', function (e) { |
| 438 | + if (!isDropdownVisible) return; | |
| 436 | 439 | const clickTarget = $(e.target); |
| 437 | 440 | const noCloseTargets = ['#sd_gen', '#extensionsMenuButton', '#roll_dice']; |
| 438 | 441 | if (dropdown.is(':visible') && !noCloseTargets.some(id => clickTarget.closest(id).length > 0)) { |
| 439 | 442 | $(dropdown).fadeOut(animation_duration); |
| 443 | + isDropdownVisible = false; | |
| 440 | 444 | } |
| 441 | 445 | }); |
| 442 | 446 | } |
| @@ -2874,6 +2874,7 @@ input[type=search]:focus::-webkit-search-cancel-button { | ||
| 2874 | 2874 | |
| 2875 | 2875 | .mes_block .ch_name { |
| 2876 | 2876 | max-width: 100%; |
| 2877 | + min-height: 22px; | |
| 2877 | 2878 | } |
| 2878 | 2879 | |
| 2879 | 2880 | /*applies to both groups and solos chars in the char list*/ |
| @@ -4043,7 +4044,7 @@ input[type="range"]::-webkit-slider-thumb { | ||
| 4043 | 4044 | .mes_button, |
| 4044 | 4045 | .extraMesButtons>div { |
| 4045 | 4046 | cursor: pointer; |
| 4046 | 4047 | transition: opacity 0.3s2s ease-in-out; |
| 4047 | 4048 | filter: drop-shadow(0px 0px 2px black); |
| 4048 | 4049 | opacity: 0.3; |
| 4049 | 4050 | padding: 1px 3px; |