Skip to content

Commit cc4dc94

Browse files
committed
xd v1.1.3
- Added a setting to address #7. It allows you to have the height of the preview tab be larger than the browser window for non html previews
1 parent b1cfec3 commit cc4dc94

File tree

3 files changed

+23
-1
lines changed

3 files changed

+23
-1
lines changed

javascript/event_handlers.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,17 @@ function setSelectValue(selectPreviewModelElement, selectSDModelElement) {
5050

5151
// Is fired by automatic1111 when the UI is updated
5252
onUiUpdate(function() {
53+
// There is a script containing settings for height
54+
// Get the element and set the attribute to limit the hieght
55+
let tabEl = gradioApp().getElementById('tab_modelpreview_xd_interface');
56+
let jsonEl = gradioApp().getElementById('modelpreview_xd_setting_json');
57+
if (typeof tabEl != 'undefined' && typeof jsonEl != 'undefined') {
58+
let settingsJSON = JSON.parse(jsonEl.innerHTML);
59+
if (settingsJSON.LimitSize) {
60+
tabEl.setAttribute('limit-height', '');
61+
}
62+
}
63+
5364
// Get the select element for the SD model checkpoint
5465
const selectSDModelElement = gradioApp().querySelector('#setting_sd_model_checkpoint select');
5566
// Check if the element exists and is not null

scripts/modelpreview.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,8 @@ def on_ui_tabs():
581581
# create a gradio block
582582
with gr.Blocks() as modelpreview_interface:
583583

584+
gr.HTML(elem_id='modelpreview_xd_setting', value='<script id="modelpreview_xd_setting_json" type="application/json">{ "LimitSize": ' + ( "true" if shared.opts.model_preview_xd_limit_sizing else "false" ) + ' }</script>')
585+
584586
# create a tab for the checkpoint previews
585587
create_tab("Checkpoints", "cp",
586588
list_all_models(),
@@ -615,6 +617,7 @@ def on_ui_tabs():
615617
def on_ui_settings():
616618
section = ('model_preview_xd', "Model Preview XD")
617619
shared.opts.add_option("model_preview_xd_name_matching", shared.OptionInfo("Loose", "Name matching rule for preview files", gr.Radio, {"choices": ["Loose", "Strict", "Folder"]}, section=section))
620+
shared.opts.add_option("model_preview_xd_limit_sizing", shared.OptionInfo(True, "Limit the height of preivews to the height of the browser window (.html preview files are always limited regardless of this setting)", section=section))
618621

619622
script_callbacks.on_ui_settings(on_ui_settings)
620623
script_callbacks.on_ui_tabs(on_ui_tabs)

style.css

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,22 @@
2828
flex: 1;
2929
}
3030

31-
#tab_modelpreview_xd_interface > div {
31+
#tab_modelpreview_xd_interface:not([limit-height]) > div {
32+
height: 100%;
33+
}
34+
35+
#tab_modelpreview_xd_interface[limit-height] > div {
3236
position: absolute;
3337
top: 5px;
3438
bottom: 5px;
3539
right: 5px;
3640
left: 5px;
3741
}
3842

43+
#tab_modelpreview_xd_interface #modelpreview_xd_setting {
44+
position: absolute;
45+
}
46+
3947
#tab_modelpreview_xd_interface > div > .tabs {
4048
overflow: hidden;
4149
height: 100%;

0 commit comments

Comments
 (0)