From c4c7fceb2d4e3c4a7e96b7ef7643f47895b5a2be Mon Sep 17 00:00:00 2001 From: Saif Addin Date: Sat, 20 Nov 2021 15:49:47 +0100 Subject: [PATCH] Fixed bug introduced in 1.1.6 about Hotbar --- CHANGELOG.md | 7 +++++++ module.json | 4 ++-- modules/component/controls.js | 11 ++++------- modules/component/hotbar.js | 32 ++++++++++++-------------------- modules/component/navigation.js | 25 ++++++++++--------------- modules/component/sidebar.js | 8 +++++--- package-lock.json | 4 ++-- package.json | 2 +- styles/component/sidebar.css | 2 -- 9 files changed, 43 insertions(+), 52 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4766518..db0da26 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +### 1.1.7 +* Bugfix: Fixed Macro Hotbar forgetting position after setting change broken in 1.1.6 + +### 1.1.6 +* Bugfix: Made first time launch transitions smoother and less bumpy +* Bugfix: Minor event order corrections and optimizations + ### 1.1.5 * Enhancement: Patched foundry so already opened windows are brought to the front if they are behind other windows when reopened diff --git a/module.json b/module.json index e5d87f1..9329762 100644 --- a/module.json +++ b/module.json @@ -3,7 +3,7 @@ "title": "Minimal UI", "author": "JeansenVaars#2857", "description": "Minimal UI allows customizing Foundry interface, by hiding, collapsing or resizing specific parts.", - "version": "1.1.5", + "version": "1.1.7", "minimumCoreVersion": "0.8.9", "compatibleCoreVersion": "0.8.9", "dependencies": [ @@ -30,5 +30,5 @@ ], "url": "https://github.com/saif-ellafi/foundryvtt-minimal-ui.git", "manifest": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/latest/download/module.json", - "download": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/download/1.1.5/foundryvtt-minimal-ui_1.1.5.zip" + "download": "https://github.com/saif-ellafi/foundryvtt-minimal-ui/releases/download/1.1.7/foundryvtt-minimal-ui_1.1.7.zip" } diff --git a/modules/component/controls.js b/modules/component/controls.js index 63d23fe..062ad8b 100644 --- a/modules/component/controls.js +++ b/modules/component/controls.js @@ -207,15 +207,12 @@ export default class MinimalUIControls { } static initHooks() { - Hooks.once('renderSceneControls', async function () { - MinimalUIControls.sizeControls(); - }) - - Hooks.on('canvasPan', function () { + Hooks.once('ready', function () { MinimalUIControls.positionSidebar(); - }); + }) - Hooks.once('renderSceneControls', async function () { + Hooks.once('renderSceneControls', function () { + MinimalUIControls.sizeControls(); switch (game.settings.get('minimal-ui', 'controlsStyle')) { case 'default': { diff --git a/modules/component/hotbar.js b/modules/component/hotbar.js index 3045ac3..4c6701d 100644 --- a/modules/component/hotbar.js +++ b/modules/component/hotbar.js @@ -24,11 +24,8 @@ export default class MinimalUIHotbar { ` - static collapseHotbar(toggleId) { - let target = document.getElementById(toggleId); - if (target) { - target.click(); - } + static async collapseHotbar(toggleId) { + await ui.hotbar.collapse(); } static lockHotbar(unlock) { @@ -47,7 +44,7 @@ export default class MinimalUIHotbar { } static positionHotbar() { - let availableWidth = parseInt($("#board").css('width')); + let availableWidth = canvas.app.screen.width; switch (game.settings.get('minimal-ui', 'hotbarPosition')) { case 'default': { rootStyle.setProperty('--hotbarxpos', '220px'); @@ -142,7 +139,7 @@ export default class MinimalUIHotbar { config: true, type: String, choices: { - "shown": game.i18n.localize("MinimalUI.SettingsStartVisible"), + "shown": game.i18n.localize("MinimalUI.SettingsAlwaysVisible"), "autohide": game.i18n.localize("MinimalUI.SettingsAutoHide"), "collapsed": game.i18n.localize("MinimalUI.SettingsCollapsed"), "onlygm": game.i18n.localize("MinimalUI.SettingsOnlyGM"), @@ -196,14 +193,9 @@ export default class MinimalUIHotbar { } static initHooks() { - Hooks.on('canvasPan', function () { - MinimalUIHotbar.positionHotbar(); - }); - - Hooks.once('ready', async function () { - + Hooks.on('ready', async function() { + ui.hotbar.element.hide(); MinimalUIHotbar.positionHotbar(); - if (game.settings.get('minimal-ui', 'hotbar') !== 'hidden') { const gmCondition = game.settings.get('minimal-ui', 'hotbar') === 'onlygm'; if (gmCondition) { @@ -212,16 +204,16 @@ export default class MinimalUIHotbar { } else rootStyle.setProperty('--hotbarvis', 'visible'); } - + // Give time to auto-hide initial animations to finish + if (game.settings.get('minimal-ui', 'playerList') === 'autohide') + await new Promise(waitABit => setTimeout(waitABit, 50)); + ui.hotbar.element.show(); }); - Hooks.on('renderHotbar', async function () { - + Hooks.on('renderHotbar', function () { MinimalUIHotbar.configureHotbar(); - MinimalUIHotbar.setHotbarSlots(); - - }) + }); } diff --git a/modules/component/navigation.js b/modules/component/navigation.js index ca0c8eb..cf54c09 100644 --- a/modules/component/navigation.js +++ b/modules/component/navigation.js @@ -7,11 +7,8 @@ export default class MinimalUINavigation { static cssSceneNavSmallLogoStart = '75px'; static cssSceneNavBullseyeStart = '125px'; - static collapseNavigation() { - let target = document.getElementById("nav-toggle"); - if (target) { - target.click(); - } + static async collapseNavigation() { + await ui.nav.collapse(); } static initSettings() { @@ -58,11 +55,17 @@ export default class MinimalUINavigation { } } + // Compatibility Workaround for bullseye module + if (game.modules.has('bullseye') && game.modules.get('bullseye').active) { + rootStyle.setProperty('--navixpos', MinimalUINavigation.cssSceneNavBullseyeStart); + } + }); + + Hooks.once('renderSceneNavigation', async function () { + switch (game.settings.get('minimal-ui', 'sceneNavigation')) { case 'collapsed': { - await new Promise(waitABit => setTimeout(waitABit, 10)); MinimalUINavigation.collapseNavigation(); - await new Promise(waitABit => setTimeout(waitABit, 250)); rootStyle.setProperty('--navivis', 'visible'); break; } @@ -72,14 +75,6 @@ export default class MinimalUINavigation { } } - // Compatibility Workaround for bullseye module - if (game.modules.has('bullseye') && game.modules.get('bullseye').active) { - rootStyle.setProperty('--navixpos', MinimalUINavigation.cssSceneNavBullseyeStart); - } - }); - - Hooks.once('renderSceneNavigation', async function () { - switch (game.settings.get('minimal-ui', 'sceneNavigationSize')) { case 'standard': { rootStyle.setProperty('--navilh', '32px'); diff --git a/modules/component/sidebar.js b/modules/component/sidebar.js index a8aee57..df158b9 100644 --- a/modules/component/sidebar.js +++ b/modules/component/sidebar.js @@ -27,10 +27,12 @@ export default class MinimalUISidebar { break; } case 'collapsed': { - await new Promise(waitABit => setTimeout(waitABit, 100)); - await ui.sidebar.collapse(); - await new Promise(waitABit => setTimeout(waitABit, 400)); + ui.sidebar.element.hide(); + ui.sidebar.collapse(); + // wait for animation to finish + await new Promise(waitABit => setTimeout(waitABit, 600)); rootStyle.setProperty('--controlsvis', 'visible'); + ui.sidebar.element.fadeIn('slow'); break; } default: { diff --git a/package-lock.json b/package-lock.json index e7d3f17..2a8f9e5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "foundryvtt-minimal-ui", - "version": "1.1.5", + "version": "1.1.7", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "foundryvtt-minimal-ui", - "version": "1.1.5", + "version": "1.1.7", "license": "MIT", "dependencies": { "@rollup/plugin-json": "^4.1.0", diff --git a/package.json b/package.json index aab59d2..471cbb9 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "foundryvtt-minimal-ui", - "version": "1.1.5", + "version": "1.1.7", "description": "Minimal UI allows customizing Foundry interface, by hiding, collapsing or resizing specific parts.", "main": "minimalui.js", "scripts": { diff --git a/styles/component/sidebar.css b/styles/component/sidebar.css index 1bbc376..892f1e3 100644 --- a/styles/component/sidebar.css +++ b/styles/component/sidebar.css @@ -4,12 +4,10 @@ #sidebar.collapsed { opacity: var(--opacity); - transition: 0.05s ease-out 0.5s; } #sidebar.collapsed:hover { opacity: 100%; - transition: 0.05s; } #sidebar-tabs {