mirror of
https://github.com/iNavFlight/inav-configurator.git
synced 2025-07-16 21:05:28 +03:00
Make tab loading async safe and add a small animation
Tab loading was relying on replacing the contents of '#content' with the loading indicator, then replacing it with the loading tab content and blocking rendering until the tab was ready by not yielding. This is problematic for tabs that load some data asynchronously, like PID and OSD. Instead, put the loading indicator in front of everything else and load new content inside '#content' next to the loading indicator (but without showing it). Once the content and data are fully loaded we fade out the loading indicator with a 0.4s long animation and then we remove. This works for both synchronous and asynchonous loading of tabs.
This commit is contained in:
parent
ab011139be
commit
0e01133fc9
28 changed files with 62 additions and 29 deletions
20
js/gui.js
20
js/gui.js
|
@ -128,7 +128,7 @@ GUI_control.prototype.switchery = function() {
|
|||
|
||||
|
||||
GUI_control.prototype.content_ready = function (callback) {
|
||||
|
||||
const content = $('#content').removeClass('loading');
|
||||
$('.togglesmall').each(function(index, elem) {
|
||||
var switchery = new Switchery(elem, {
|
||||
size: 'small',
|
||||
|
@ -190,7 +190,13 @@ GUI_control.prototype.content_ready = function (callback) {
|
|||
});
|
||||
});
|
||||
|
||||
if (callback) callback();
|
||||
const duration = content.data('empty') ? 0 : 400;
|
||||
$('#content .data-loading').fadeOut(duration, function() {
|
||||
$(this).remove();
|
||||
});
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
};
|
||||
|
||||
GUI_control.prototype.updateStatusBar = function() {
|
||||
|
@ -243,5 +249,15 @@ GUI_control.prototype.simpleBind = function () {
|
|||
});
|
||||
};
|
||||
|
||||
GUI_control.prototype.load = function(rel, callback) {
|
||||
const content = $('#content').addClass('loading');
|
||||
$.get(rel, function(data) {
|
||||
$(data).appendTo(content);
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// initialize object into GUI variable
|
||||
var GUI = new GUI_control();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue