Files
wekan/client/lib/dragscrollTouch.js
T
Lauri Ojansivu 6f021aa387 Mobile / touch fixes (Fairphone 4 postmarketOS Firefox and Fairphone 4 Ubuntu Touch Morph browser; iPhone 12 Mini was already correct):
- Fixed one-finger drag-to-scroll not working in the All Boards view and the
  Calendar view on Fairphone 4 Firefox and Ubuntu Touch Morph. These browsers
  do not emit the synthetic mouse events the `@wekanteam/dragscroll` library
  relies on, so scrolling only worked in the Swimlanes/Lists views. Added a new
  native touch-scrolling helper `client/lib/dragscrollTouch.js` that scrolls the
  nearest `.dragscroll` container with a one-finger drag (iOS is skipped, since
  native momentum scrolling already works there), and added the `dragscroll`
  class to the All Boards list and the Calendar view.
- Fixed all text, buttons, the All Boards tables and the top bars (header and
  the second bar) rendering about 2x too large on Fairphone 4. `getMobileMode()`
  defaulted to mobile mode only for iPhone, so every other phone fell back to
  desktop mode, whose large desktop sizing looks oversized on a small phone
  screen. The default is now mobile mode for any phone-sized touch device
  (iPhone, Android/Mobile browsers, Ubuntu Touch, or a coarse-pointer touch
  screen with viewport width ≤ 800px); desktop browsers stay in desktop mode and
  the user's own Mobile/Desktop toggle still takes priority.
- Fixed not being able to reorder swimlanes and lists by dragging their drag
  handle on touch devices. The new touch-scroll helper was hijacking touches
  that started on a drag handle; `.handle` / `.ui-sortable-handle` elements are
  now excluded from touch-scrolling so dragging the handle reorders as expected.
- Fixed a card duplicating into two cards when it was dragged by its title-row
  drag handle while its Card Details panel was open. The card sortable in
  `client/components/lists/list.js` was re-initialized on every list re-render
  without first destroying the previous instance, so two `stop` handlers fired
  per drag. It now destroys any existing sortable before re-initializing, the
  same guard already used for swimlanes.

Attachment storage:

- Added configurable attachment storage backends in the admin panel: choose the
  default save storage and store attachments on the local filesystem, GridFS, or
  cloud object storage — S3-compatible (AWS S3, MinIO, Cloudflare R2, Backblaze
  B2, Wasabi, DigitalOcean Spaces), Azure Blob Storage, or Google Cloud Storage
  — via the `@tweedegolf/storage-abstraction` adapters (new
  `models/lib/cloudStorage.js`). Includes a "Test connection" action and
  English translations for the new settings.
- Added a server-side bulk attachment move (new `server/attachmentBulkMove.js`
  and `models/attachmentBulkMoveStatus.js`) that moves all attachments from one
  storage backend to another as a background job whose progress survives the
  admin navigating away from or closing the page.

Thanks to xet7.
2026-05-31 11:12:41 +03:00

86 lines
3.4 KiB
JavaScript

// Native one-finger touch scrolling for `.dragscroll` containers.
//
// The @wekanteam/dragscroll library only listens for mouse events
// (mousedown / mousemove / mouseup). On iPad / iPhone Safari finger
// scrolling of those containers works anyway, because they are also native
// overflow scrollers with momentum scrolling. But on Fairphone 4 postmarketOS
// Firefox and on the newer Ubuntu Touch Morph Browser, dragging a finger over
// a `.dragscroll` container (All Boards list, board canvas, swimlanes, lists,
// calendar) did not scroll it, because those browsers do not emit the
// synthetic mouse events dragscroll relies on.
//
// This module adds real touch handling so a one-finger drag scrolls the
// nearest `.dragscroll` ancestor on every touch browser. It mirrors the
// behaviour of dragscroll's mouse handler (same `.nodragscroll` / form-field
// exclusions) and is delegated on `document`, so it also covers `.dragscroll`
// elements that are added or replaced reactively without needing a reset.
//
// iOS is intentionally skipped: there finger scrolling already works natively
// (with momentum), and taking it over with preventDefault would only remove
// that momentum.
const isIOS = /iP(hone|ad|od)/.test(navigator.userAgent);
let active = null;
function isExcluded(target) {
return !!(
target.closest &&
target.closest(
// Form fields and editors must keep their own touch behaviour, and
// `.nodragscroll` opts an element out explicitly. `.handle` (the
// swimlane/list drag handles, .js-swimlane-header-handle /
// .js-list-handle) must be excluded too: those start a jQuery UI
// sortable reorder via touch-punch, and hijacking the touch to scroll
// here would block dragging the handle to reorder swimlanes/lists.
'input, select, textarea, .note-editable, .nodragscroll, .handle, .ui-sortable-handle',
)
);
}
function canScroll(el) {
return el.scrollHeight > el.clientHeight || el.scrollWidth > el.clientWidth;
}
function onTouchStart(e) {
active = null;
if (e.touches.length !== 1) return;
const target = e.target;
if (isExcluded(target)) return;
const el = target.closest && target.closest('.dragscroll');
if (!el || !canScroll(el)) return;
const touch = e.touches[0];
active = {
el,
startX: touch.clientX,
startY: touch.clientY,
scrollLeft: el.scrollLeft,
scrollTop: el.scrollTop,
};
}
function onTouchMove(e) {
if (!active || e.touches.length !== 1) return;
const touch = e.touches[0];
const el = active.el;
el.scrollLeft = active.scrollLeft - (touch.clientX - active.startX);
el.scrollTop = active.scrollTop - (touch.clientY - active.startY);
// We own the gesture: suppress page rubber-banding and the synthetic mouse
// events that would otherwise double-scroll through dragscroll.
if (e.cancelable) e.preventDefault();
}
function onTouchEnd() {
active = null;
}
// Guard so importing this module from more than one place (boardBody,
// boardsList, ...) still only attaches the listeners once.
if (!isIOS && typeof document !== 'undefined' && !window.__wekanDragscrollTouch) {
window.__wekanDragscrollTouch = true;
document.addEventListener('touchstart', onTouchStart, { passive: true });
document.addEventListener('touchmove', onTouchMove, { passive: false });
document.addEventListener('touchend', onTouchEnd, { passive: true });
document.addEventListener('touchcancel', onTouchEnd, { passive: true });
}