Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| dbfe98b3c7 | |||
| 3beaa88fe9 | |||
| dcb672777d |
@@ -48,3 +48,24 @@
|
|||||||
.sv-top-scroll-inner {
|
.sv-top-scroll-inner {
|
||||||
height: 1px;
|
height: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Click-and-drag horizontal scrolling (added by Asset/js/drag-scroll.js when the
|
||||||
|
* "Drag the board background to scroll" setting is enabled). The .sv-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.sv-drag-scroll {
|
||||||
|
cursor: grab;
|
||||||
|
}
|
||||||
|
|
||||||
|
#board-container.sv-drag-scroll .task-board {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.sv-grabbing,
|
||||||
|
.sv-grabbing * {
|
||||||
|
cursor: grabbing !important;
|
||||||
|
user-select: none !important;
|
||||||
|
}
|
||||||
|
|||||||
75
Asset/js/drag-scroll.js
Normal file
75
Asset/js/drag-scroll.js
Normal file
@@ -0,0 +1,75 @@
|
|||||||
|
/*
|
||||||
|
* ShrinkVertically -- 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-sv-drag") === "1") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
container.setAttribute("data-sv-drag", "1");
|
||||||
|
container.classList.add("sv-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("sv-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("sv-grabbing");
|
||||||
|
}
|
||||||
|
|
||||||
|
document.addEventListener("mouseup", stop);
|
||||||
|
document.addEventListener("mouseleave", stop);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (document.readyState === "loading") {
|
||||||
|
document.addEventListener("DOMContentLoaded", init);
|
||||||
|
} else {
|
||||||
|
init();
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -18,12 +18,14 @@ class ConfigController extends BaseController
|
|||||||
{
|
{
|
||||||
$offset = (int) $this->configModel->get('shrink_vertically_offset', self::DEFAULT_OFFSET);
|
$offset = (int) $this->configModel->get('shrink_vertically_offset', self::DEFAULT_OFFSET);
|
||||||
$topScrollbar = (int) $this->configModel->get('shrink_vertically_top_scrollbar', 0);
|
$topScrollbar = (int) $this->configModel->get('shrink_vertically_top_scrollbar', 0);
|
||||||
|
$dragScroll = (int) $this->configModel->get('shrink_vertically_drag_scroll', 0);
|
||||||
|
|
||||||
$this->response->html($this->helper->layout->config('shrinkVertically:config/show', array(
|
$this->response->html($this->helper->layout->config('shrinkVertically:config/show', array(
|
||||||
'title' => t('Settings').' > '.t('Shrink Vertically'),
|
'title' => t('Settings').' > '.t('Shrink Vertically'),
|
||||||
'values' => array(
|
'values' => array(
|
||||||
'shrink_vertically_offset' => $offset,
|
'shrink_vertically_offset' => $offset,
|
||||||
'shrink_vertically_top_scrollbar' => $topScrollbar,
|
'shrink_vertically_top_scrollbar' => $topScrollbar,
|
||||||
|
'shrink_vertically_drag_scroll' => $dragScroll,
|
||||||
),
|
),
|
||||||
'errors' => array(),
|
'errors' => array(),
|
||||||
)));
|
)));
|
||||||
@@ -37,10 +39,12 @@ class ConfigController extends BaseController
|
|||||||
$offset = max(self::MIN_OFFSET, min(self::MAX_OFFSET, $offset));
|
$offset = max(self::MIN_OFFSET, min(self::MAX_OFFSET, $offset));
|
||||||
|
|
||||||
$topScrollbar = isset($values['shrink_vertically_top_scrollbar']) ? 1 : 0;
|
$topScrollbar = isset($values['shrink_vertically_top_scrollbar']) ? 1 : 0;
|
||||||
|
$dragScroll = isset($values['shrink_vertically_drag_scroll']) ? 1 : 0;
|
||||||
|
|
||||||
if ($this->configModel->save(array(
|
if ($this->configModel->save(array(
|
||||||
'shrink_vertically_offset' => $offset,
|
'shrink_vertically_offset' => $offset,
|
||||||
'shrink_vertically_top_scrollbar' => $topScrollbar,
|
'shrink_vertically_top_scrollbar' => $topScrollbar,
|
||||||
|
'shrink_vertically_drag_scroll' => $dragScroll,
|
||||||
))) {
|
))) {
|
||||||
$this->flash->success(t('Settings saved successfully.'));
|
$this->flash->success(t('Settings saved successfully.'));
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -32,6 +32,13 @@ class Plugin extends Base
|
|||||||
'template' => 'plugins/ShrinkVertically/Asset/js/top-scrollbar.js',
|
'template' => 'plugins/ShrinkVertically/Asset/js/top-scrollbar.js',
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Optional: click-and-drag the board background to scroll horizontally.
|
||||||
|
if ((int) $this->configModel->get('shrink_vertically_drag_scroll', 0) === 1) {
|
||||||
|
$this->hook->on('template:layout:js', array(
|
||||||
|
'template' => 'plugins/ShrinkVertically/Asset/js/drag-scroll.js',
|
||||||
|
));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginName()
|
public function getPluginName()
|
||||||
@@ -51,7 +58,7 @@ class Plugin extends Base
|
|||||||
|
|
||||||
public function getPluginVersion()
|
public function getPluginVersion()
|
||||||
{
|
{
|
||||||
return '1.0.0';
|
return '1.1.0';
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getPluginHomepage()
|
public function getPluginHomepage()
|
||||||
|
|||||||
21
README.md
21
README.md
@@ -1,9 +1,10 @@
|
|||||||
# ShrinkVertically -- keep the board horizontal scrollbar visible
|
# ShrinkVertically -- keep the board horizontal scrollbar visible
|
||||||
|
|
||||||
A small Kanboard plugin focused on the board's horizontal scrollbar. It fixes the
|
A small Kanboard plugin focused on getting around the board horizontally. It fixes the
|
||||||
vertically-collapsed board view so the bottom scrollbar stays on screen, and can
|
vertically-collapsed board view so the bottom scrollbar stays on screen, can optionally
|
||||||
optionally add a second, mirrored horizontal scrollbar above the columns. Both are
|
add a second mirrored scrollbar above the columns, and can optionally let you drag the
|
||||||
configurable under "Settings -> Shrink Vertically".
|
board background to scroll (like Trello). Everything is configurable under
|
||||||
|
"Settings -> Shrink Vertically".
|
||||||
|
|
||||||
## The problem
|
## The problem
|
||||||
|
|
||||||
@@ -71,6 +72,16 @@ a second, mirrored scrollbar just above the columns. A small script
|
|||||||
strip above `#board-container` and keeps its scroll position in sync with the board both
|
strip above `#board-container` and keeps its scroll position in sync with the board both
|
||||||
ways.
|
ways.
|
||||||
|
|
||||||
|
## Drag to scroll (optional)
|
||||||
|
|
||||||
|
Kanboard has no way to pan the board by grabbing it; you must use the scrollbar. Enable
|
||||||
|
"Drag the board background to scroll" to click and drag on the empty board background to
|
||||||
|
scroll the columns sideways, like the Trello board canvas. A small script
|
||||||
|
(`Asset/js/drag-scroll.js`, loaded only when the option is on) starts a horizontal pan on
|
||||||
|
`#board-container` only when the press lands on empty background -- pressing a task card,
|
||||||
|
a drag handle or any control is ignored, so Kanboard's own card and column drag-and-drop
|
||||||
|
keep working unchanged.
|
||||||
|
|
||||||
## Settings
|
## Settings
|
||||||
|
|
||||||
Go to "Settings -> Shrink Vertically":
|
Go to "Settings -> Shrink Vertically":
|
||||||
@@ -81,6 +92,8 @@ Go to "Settings -> Shrink Vertically":
|
|||||||
header); decrease it to make the collapsed columns taller. Default: 240.
|
header); decrease it to make the collapsed columns taller. Default: 240.
|
||||||
- **Add a top horizontal scrollbar to the board** -- toggles the mirrored top scrollbar
|
- **Add a top horizontal scrollbar to the board** -- toggles the mirrored top scrollbar
|
||||||
described above.
|
described above.
|
||||||
|
- **Drag the board background to scroll horizontally** -- toggles the Trello-style
|
||||||
|
click-and-drag panning described above.
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,13 @@
|
|||||||
</p>
|
</p>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
|
|
||||||
|
<fieldset>
|
||||||
|
<?= $this->form->checkbox('shrink_vertically_drag_scroll', t('Drag the board background to scroll horizontally'), 1, isset($values['shrink_vertically_drag_scroll']) && $values['shrink_vertically_drag_scroll'] == 1) ?>
|
||||||
|
<p class="form-help">
|
||||||
|
<?= t('Like Trello: click and drag on the empty board background to scroll the columns sideways. Dragging a task card or a handle still works as usual.') ?>
|
||||||
|
</p>
|
||||||
|
</fieldset>
|
||||||
|
|
||||||
<div class="form-actions">
|
<div class="form-actions">
|
||||||
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
<button type="submit" class="btn btn-blue"><?= t('Save') ?></button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user