Fix kanban rendering issues

pull/1/head
yflory 4 years ago
parent c04c22cbb8
commit 98cc87888e

@ -1,9 +1,10 @@
define([ define([
'jquery', 'jquery',
'/customize/messages.js', '/customize/messages.js',
'/common/common-util.js',
'/common/visible.js', '/common/visible.js',
'/bower_components/dragula.js/dist/dragula.min.js', '/bower_components/dragula.js/dist/dragula.min.js',
], function ($, Messages, Visible, Dragula) { ], function ($, Messages, Util, Visible, Dragula) {
/** /**
* jKanban * jKanban
* Vanilla Javascript plugin for manage kanban boards * Vanilla Javascript plugin for manage kanban boards
@ -740,7 +741,6 @@ define([
return self; return self;
}; };
var todoOnVisible = function () {};
var onVisibleHandler = false; var onVisibleHandler = false;
this.setBoards = function (boards) { this.setBoards = function (boards) {
var scroll = {}; var scroll = {};
@ -750,15 +750,23 @@ define([
// Get horizontal scroll // Get horizontal scroll
var $el = $(self.element); var $el = $(self.element);
var scrollLeft = $el.scrollLeft(); var scrollLeft = $el.scrollLeft();
// Get existing boards list
var list = Util.clone(this.options.boards.list);
// Update memory
this.options.boards = boards;
// If the tab is not focused but a handler already exists: abort
if (!Visible.currently() && onVisibleHandler) { return; }
var todoOnVisible = function () {
// Remove all boards // Remove all boards
for (var i in this.options.boards.list) { for (var i in list) {
var boardkey = this.options.boards.list[i]; var boardkey = list[i];
scroll[boardkey] = $('.kanban-board[data-id="'+boardkey+'"] .kanban-drag').scrollTop(); scroll[boardkey] = $('.kanban-board[data-id="'+boardkey+'"] .kanban-drag').scrollTop();
this.removeBoard(boardkey); self.removeBoard(boardkey);
} }
this.options.boards = boards;
todoOnVisible = function () {
// Add all new boards // Add all new boards
self.addBoards(); self.addBoards();
self.options.refresh(); self.options.refresh();
@ -772,7 +780,6 @@ define([
// If the tab is not focused, redraw on focus // If the tab is not focused, redraw on focus
if (!Visible.currently()) { if (!Visible.currently()) {
if (onVisibleHandler) { return; }
onVisibleHandler = true; onVisibleHandler = true;
return void Visible.onChange(function (visible) { return void Visible.onChange(function (visible) {
if (!visible) { return; } if (!visible) { return; }

Loading…
Cancel
Save