debian-mirror-gitlab/app/assets/javascripts/sortable/utils.js
2022-06-21 17:19:12 +05:30

31 lines
729 B
JavaScript

/* global DocumentTouch */
import { defaultSortableOptions } from './constants';
export function sortableStart() {
document.body.classList.add('is-dragging');
}
export function sortableEnd() {
document.body.classList.remove('is-dragging');
}
export function getSortableDefaultOptions(options) {
const touchEnabled =
'ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch);
const defaultSortOptions = {
...defaultSortableOptions,
filter: '.no-drag',
delay: touchEnabled ? 100 : 0,
scrollSensitivity: touchEnabled ? 60 : 100,
scrollSpeed: 20,
onStart: sortableStart,
onEnd: sortableEnd,
};
return {
...defaultSortOptions,
...options,
};
}