Skip to content

Commit 13248a9

Browse files
committed
feat: add support for fadeIn effect for UIWindow
1 parent 99ce3bd commit 13248a9

File tree

2 files changed

+50
-19
lines changed

2 files changed

+50
-19
lines changed

src/gui/src/UI/UIWindow.js

+49-19
Original file line numberDiff line numberDiff line change
@@ -589,25 +589,55 @@ async function UIWindow(options) {
589589
// window is actually appended and usable.
590590
// NOTE: there is another is_visible condition below
591591
if ( options.is_visible ) {
592-
$(el_window).show(0, function(e){
593-
// if SaveFileDialog, bring focus to the el_savefiledialog_filename and select all
594-
if(options.is_saveFileDialog){
595-
let item_name = el_savefiledialog_filename.value;
596-
const extname = path.extname('/' + item_name);
597-
if(extname !== '')
598-
el_savefiledialog_filename.setSelectionRange(0, item_name.length - extname.length)
599-
else
600-
$(el_savefiledialog_filename).select();
601-
602-
$(el_savefiledialog_filename).get(0).focus({preventScroll:true});
603-
}
604-
//set custom window css
605-
$(el_window).css(options.window_css);
606-
// onAppend()
607-
if(options.onAppend && typeof options.onAppend === 'function'){
608-
options.onAppend(el_window);
609-
}
610-
});
592+
593+
if(options.fadeIn){
594+
$(el_window).css('opacity', 0);
595+
596+
$(el_window).animate({ opacity: 1 }, options.fadeIn, function() {
597+
// Move the onAppend callback here to ensure it's called after fade-in
598+
if (options.is_visible) {
599+
$(el_window).show(0, function(e) {
600+
// if SaveFileDialog, bring focus to the el_savefiledialog_filename and select all
601+
if (options.is_saveFileDialog) {
602+
let item_name = el_savefiledialog_filename.value;
603+
const extname = path.extname('/' + item_name);
604+
if (extname !== '')
605+
el_savefiledialog_filename.setSelectionRange(0, item_name.length - extname.length);
606+
else
607+
$(el_savefiledialog_filename).select();
608+
609+
$(el_savefiledialog_filename).get(0).focus({preventScroll:true});
610+
}
611+
//set custom window css
612+
$(el_window).css(options.window_css);
613+
// onAppend()
614+
if (options.onAppend && typeof options.onAppend === 'function') {
615+
options.onAppend(el_window);
616+
}
617+
});
618+
}
619+
});
620+
}else{
621+
$(el_window).show(0, function(e){
622+
// if SaveFileDialog, bring focus to the el_savefiledialog_filename and select all
623+
if(options.is_saveFileDialog){
624+
let item_name = el_savefiledialog_filename.value;
625+
const extname = path.extname('/' + item_name);
626+
if(extname !== '')
627+
el_savefiledialog_filename.setSelectionRange(0, item_name.length - extname.length)
628+
else
629+
$(el_savefiledialog_filename).select();
630+
631+
$(el_savefiledialog_filename).get(0).focus({preventScroll:true});
632+
}
633+
//set custom window css
634+
$(el_window).css(options.window_css);
635+
// onAppend()
636+
if(options.onAppend && typeof options.onAppend === 'function'){
637+
options.onAppend(el_window);
638+
}
639+
});
640+
}
611641
}
612642

613643
if(options.is_saveFileDialog){

src/gui/src/UI/UIWindowWelcome.js

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ async function UIWindowWelcome(options){
6767
dominant: true,
6868
show_in_taskbar: false,
6969
draggable_body: true,
70+
fadeIn: 1000,
7071
onAppend: function(this_window){
7172
},
7273
window_class: 'window-welcome',

0 commit comments

Comments
 (0)