浏览代码

feat: add support for `fadeIn` effect for `UIWindow`

jelveh 1 天之前
父节点
当前提交
13248a99bf
共有 2 个文件被更改,包括 50 次插入19 次删除
  1. 49 19
      src/gui/src/UI/UIWindow.js
  2. 1 0
      src/gui/src/UI/UIWindowWelcome.js

+ 49 - 19
src/gui/src/UI/UIWindow.js

@@ -589,25 +589,55 @@ async function UIWindow(options) {
     // window is actually appended and usable.
     // window is actually appended and usable.
     // NOTE: there is another is_visible condition below
     // NOTE: there is another is_visible condition below
     if ( options.is_visible ) {
     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){
     if(options.is_saveFileDialog){

+ 1 - 0
src/gui/src/UI/UIWindowWelcome.js

@@ -67,6 +67,7 @@ async function UIWindowWelcome(options){
         dominant: true,
         dominant: true,
         show_in_taskbar: false,
         show_in_taskbar: false,
         draggable_body: true,
         draggable_body: true,
+        fadeIn: 1000,
         onAppend: function(this_window){
         onAppend: function(this_window){
         },
         },
         window_class: 'window-welcome',
         window_class: 'window-welcome',