assets added css js

This commit is contained in:
2026-07-01 09:51:15 -03:00
parent 29ed19b4cb
commit c6f7ee297b
2 changed files with 101 additions and 0 deletions

26
Asset/css/tweak-drag.css Normal file
View File

@@ -0,0 +1,26 @@
/*
* TweakDrag -- board drag/touch and column-gap tweaks.
*
* The wider column gap is applied conditionally from Template/layout/variable.php (only
* when the "Widen the gap between columns" setting is on), using border-spacing with the
* --td-column-gap value, so it is not in this static stylesheet.
*
* Below: click-and-drag horizontal scrolling (added by Asset/js/drag-scroll.js when the
* "Drag the board background to scroll" setting is enabled). The .td-drag-scroll class is
* set on #board-container by the script, so these rules are inert when disabled. A grab
* cursor advertises the empty background; cards keep the normal cursor since pressing them
* does a card drag, not a pan.
*/
#board-container.td-drag-scroll {
cursor: grab;
}
#board-container.td-drag-scroll .task-board {
cursor: default;
}
.td-grabbing,
.td-grabbing * {
cursor: grabbing !important;
user-select: none !important;
}

75
Asset/js/drag-scroll.js Normal file
View File

@@ -0,0 +1,75 @@
/*
* TweakDrag -- optional click-and-drag horizontal scrolling of the board.
*
* Like the Trello board canvas: press the empty board background and drag left/right
* to scroll #board-container horizontally. The pan only starts on empty background --
* pressing a task card, a drag handle, or any interactive control is ignored, so this
* never interferes with Kanboard's own card and column drag-and-drop.
*
* Loaded only when the "Drag the board background to scroll" setting is enabled.
*/
(function () {
"use strict";
// Pressing any of these (or their descendants) must NOT start a background pan.
var IGNORE = "a, button, input, textarea, select, label, " +
".task-board, [data-task-id], .task-board-sort-handle, " +
".draggable-row-handle, .dropdown, .ui-sortable-handle";
function isIgnored(el) {
return !!(el && el.closest && el.closest(IGNORE));
}
function init() {
var container = document.getElementById("board-container");
if (!container || container.getAttribute("data-td-drag") === "1") {
return;
}
container.setAttribute("data-td-drag", "1");
container.classList.add("td-drag-scroll");
var dragging = false;
var startX = 0;
var startScrollLeft = 0;
container.addEventListener("mousedown", function (e) {
// Left button only, and only on empty board background.
if (e.button !== 0 || isIgnored(e.target)) {
return;
}
dragging = true;
startX = e.clientX;
startScrollLeft = container.scrollLeft;
container.classList.add("td-grabbing");
e.preventDefault();
});
document.addEventListener("mousemove", function (e) {
if (!dragging) {
return;
}
container.scrollLeft = startScrollLeft - (e.clientX - startX);
e.preventDefault();
});
function stop() {
if (!dragging) {
return;
}
dragging = false;
container.classList.remove("td-grabbing");
}
document.addEventListener("mouseup", stop);
document.addEventListener("mouseleave", stop);
}
if (document.readyState === "loading") {
document.addEventListener("DOMContentLoaded", init);
} else {
init();
}
})();