mirror of
https://github.com/HeyPuter/puter
synced 2024-11-14 22:06:00 +00:00
feat: add support for fadeIn
effect for UIWindow
This commit is contained in:
parent
99ce3bde19
commit
13248a99bf
@ -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){
|
||||
|
@ -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',
|
||||
|
Loading…
Reference in New Issue
Block a user