Add HTML buffer to reduce flicker on AJAX menu update. GitLab issue #511.

Signed-off-by: Roberto Rosario <roberto.rosario.gonzalez@gmail.com>
This commit is contained in:
Roberto Rosario
2018-09-12 14:17:19 -04:00
parent c82125c611
commit bc398d79cf
2 changed files with 11 additions and 2 deletions

View File

@@ -115,6 +115,9 @@ class MayanApp {
doRefreshMainMenu (options) {
var self = this;
var $mainMenu = $('#main-menu');
var $mainMenuBuffer = $('#main-menu-buffer');
$.ajax({
complete: function() {
setTimeout(app.doRefreshMainMenu, options.interval, options);
@@ -123,7 +126,12 @@ class MayanApp {
var $elements = $('.dropdown.open');
if ($elements.length === 0) {
// Don't refresh the HTML if there are open dropdowns
$('#main-menu').html(data);
$mainMenuBuffer.html(data);
$mainMenuBuffer.show();
$mainMenu.hide();
$mainMenu.html($mainMenuBuffer.html());
$mainMenu.show();
$mainMenuBuffer.hide();
}
},
url: options.url,
@@ -240,7 +248,7 @@ class MayanApp {
setTimeout(
function () {
self.callbackAJAXSpinnerUpdate();
}, 350
}, 450
);
});

View File

@@ -36,6 +36,7 @@
<div id="main-menu">
{% include 'appearance/main_menu.html' %}
</div>
<div id="main-menu-buffer" style="display: none;"></div>
<div class="container-fluid">
<div class="row">
<div class="col-xs-12">