Skip to content

Commit

Permalink
feat: add support for fadeIn effect for UIWindow
Browse files Browse the repository at this point in the history
  • Loading branch information
jelveh committed Oct 21, 2024
1 parent 99ce3bd commit 13248a9
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 19 deletions.
68 changes: 49 additions & 19 deletions src/gui/src/UI/UIWindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -589,25 +589,55 @@ async function UIWindow(options) {
// window is actually appended and usable.
// NOTE: there is another is_visible condition below
if ( options.is_visible ) {
$(el_window).show(0, function(e){
// if SaveFileDialog, bring focus to the el_savefiledialog_filename and select all
if(options.is_saveFileDialog){
let item_name = el_savefiledialog_filename.value;
const extname = path.extname('/' + item_name);
if(extname !== '')
el_savefiledialog_filename.setSelectionRange(0, item_name.length - extname.length)
else
$(el_savefiledialog_filename).select();

$(el_savefiledialog_filename).get(0).focus({preventScroll:true});
}
//set custom window css
$(el_window).css(options.window_css);
// onAppend()
if(options.onAppend && typeof options.onAppend === 'function'){
options.onAppend(el_window);
}
});

if(options.fadeIn){
$(el_window).css('opacity', 0);

$(el_window).animate({ opacity: 1 }, options.fadeIn, function() {
// Move the onAppend callback here to ensure it's called after fade-in
if (options.is_visible) {
$(el_window).show(0, function(e) {
// if SaveFileDialog, bring focus to the el_savefiledialog_filename and select all
if (options.is_saveFileDialog) {
let item_name = el_savefiledialog_filename.value;
const extname = path.extname('/' + item_name);
if (extname !== '')
el_savefiledialog_filename.setSelectionRange(0, item_name.length - extname.length);
else
$(el_savefiledialog_filename).select();

$(el_savefiledialog_filename).get(0).focus({preventScroll:true});
}
//set custom window css
$(el_window).css(options.window_css);
// onAppend()
if (options.onAppend && typeof options.onAppend === 'function') {
options.onAppend(el_window);
}
});
}
});
}else{
$(el_window).show(0, function(e){
// if SaveFileDialog, bring focus to the el_savefiledialog_filename and select all
if(options.is_saveFileDialog){
let item_name = el_savefiledialog_filename.value;
const extname = path.extname('/' + item_name);
if(extname !== '')
el_savefiledialog_filename.setSelectionRange(0, item_name.length - extname.length)
else
$(el_savefiledialog_filename).select();

$(el_savefiledialog_filename).get(0).focus({preventScroll:true});
}
//set custom window css
$(el_window).css(options.window_css);
// onAppend()
if(options.onAppend && typeof options.onAppend === 'function'){
options.onAppend(el_window);
}
});
}
}

if(options.is_saveFileDialog){
Expand Down
1 change: 1 addition & 0 deletions src/gui/src/UI/UIWindowWelcome.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ async function UIWindowWelcome(options){
dominant: true,
show_in_taskbar: false,
draggable_body: true,
fadeIn: 1000,
onAppend: function(this_window){
},
window_class: 'window-welcome',
Expand Down

0 comments on commit 13248a9

Please sign in to comment.