T
TyphonJS9mo ago
Vauxs

ApplicationShell, elementRoot, and reactive offsetHeight with resizable: true

I am trying to make a menu that requires a bit of JS in order to work to set maximum heights for lists that otherwise should scroll. Problem is that I cannot find a way to get an up to date elementRoot.offsetHeight when the user resizes the application window. Is there a way to get those values?
32 Replies
Vauxs
VauxsOP9mo ago
Looks like there is some kind of resizeObserver action I could use? Basically I need to find a way to get the size of the ApplicationShell
TyphonJS (Michael)
I'm not sure of the exact design of your menu, but have you checked out TJSContextMenu / for context menus and TJSMenu from #standard/component for in app pop overs usually activated by TJSToggleIconButton?
Vauxs
VauxsOP9mo ago
I forgot about getContext("#external"); :facepalmpicard: No, but its very unlikely this is what I want
TyphonJS (Michael)
What do you want?
Vauxs
VauxsOP9mo ago
I have a list that takes up the entire height of an application but once it overflows, it expands the entire application downward Instead, I want only the list itself to have overflow-scroll
Vauxs
VauxsOP9mo ago
TyphonJS (Michael)
You can use TJSContextMenu or TJSMenu and embed your own Svelte component for the content if you need something custom.
Vauxs
VauxsOP9mo ago
I unfortunately do not understand how this helps. Either way I found what I needed
const { application } = getContext("#external");
application.position.stores.height.subscribe((height) => {
console.log(height);
});
const { application } = getContext("#external");
application.position.stores.height.subscribe((height) => {
console.log(height);
});
TyphonJS (Michael)
Sure... You could also just create a grid layout for left / right sections that takes up the whole space and make the child / left side overflow-y: auto. I think you may be overcomplicating things as CSS layout of the content area should suffice without JS / manual monitoring of the height of the app.
Vauxs
VauxsOP9mo ago
The issue is that there are also buttons at the bottom I mean I will gladly look into a pure CSS solution its just that using height so far has been the only thing I seen work
TyphonJS (Michael)
The left hand menu can be divided into a flex layout with the bottom button row having a set height with the menu taking the rest. I do think there is a CSS / layout solution to pursue before turning to a JS solution.
Vauxs
VauxsOP9mo ago
because the issue is that the user can do this
Vauxs
VauxsOP9mo ago
While I want the buttons to always be visible
No description
TyphonJS (Michael)
You just need to adjust the manu to respond accordingly.
Wasp
Wasp9mo ago
The button element could have a fixed bottom position, and the list could have a max-height 100% minus the button element height But I ain't no CSS savant, so take my advice with a pinch of salt
TyphonJS (Michael)
There are several ways to solve this w/ CSS. What Wasp mentioned is one of them.
Vauxs
VauxsOP9mo ago
I tried doing that, but the issue of the list not properly overflowing into a scrollbar remains
No description
Vauxs
VauxsOP9mo ago
The only thing changes is that the buttons have what amounts to absolute position at the bottom of the window
TyphonJS (Michael)
For that you have to use calc for the height for 100% - height of menu bar.
Vauxs
VauxsOP9mo ago
This is why I wanted to use JS to set the max height get the height of the window and clamp down on the elements because otherwise resize just hides them
Wasp
Wasp9mo ago
Is the sidebar's element somehow not max-height? Like, the parent element? The parent element could be display box, and would then conform to the content height, and if the content height is another element with max-height 100% minus the button box, that won't help since it's still 100% of a resizing box
TyphonJS (Michael)
A flex box (column) for the left hand works easily enough too where you set the top scrollable menu to flex: 1; and give height: 80px; to the menu bar and make the menu bar its own horizontal flex layout.
Vauxs
VauxsOP9mo ago
The sidebar column is already a flex col. flex: 1 with a set height does not change anything. The bottom row of buttons is already a flex-row
TyphonJS (Michael)
In general you might also be running into the annoying universal selector for the window content that is in the Foundry styles. It sets the child of .window-content IE top level to a flex of 1 automatically which will exhibit unwanted behavior for the core styles of overflow of .window-content when doing anything custom.
Vauxs
VauxsOP9mo ago
Vauxs
VauxsOP9mo ago
I'll look into that.
Vauxs
VauxsOP9mo ago
Well, overriding it sure isn't good lol
No description
TyphonJS (Michael)
I do something similar for an unreleased module, but with a top bar and a scrollable bottom that resizes to the app size appropriately. You can see here where I reverse the the Foundry universal selector scoped to the app ID: https://github.com/typhonjs-fvtt/better-macros-directory/blob/main/styles/init.scss#L20-L23 And here is the window content layout: https://github.com/typhonjs-fvtt/better-macros-directory/blob/main/src/view/dir/MacroDirectory.svelte
Vauxs
VauxsOP9mo ago
Finally got it
Vauxs
VauxsOP9mo ago
No description
Vauxs
VauxsOP9mo ago
Vauxs
VauxsOP9mo ago
Though looks like I need to make the buttons at the bottom a bit more stable but thats more doable I hope yep already done, just added height: 100% to the list
Want results from more Discord servers?
Add your server