debian-mirror-gitlab/app/assets/javascripts/sortable/utils.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
729 B
JavaScript
Raw Normal View History

2017-08-17 22:00:37 +05:30
/* global DocumentTouch */
2022-06-21 17:19:12 +05:30
import { defaultSortableOptions } from './constants';
2018-03-27 19:54:05 +05:30
2018-12-13 13:39:08 +05:30
export function sortableStart() {
2017-08-17 22:00:37 +05:30
document.body.classList.add('is-dragging');
2018-12-13 13:39:08 +05:30
}
2017-08-17 22:00:37 +05:30
2018-12-13 13:39:08 +05:30
export function sortableEnd() {
2017-08-17 22:00:37 +05:30
document.body.classList.remove('is-dragging');
2018-12-13 13:39:08 +05:30
}
2017-08-17 22:00:37 +05:30
2022-06-21 17:19:12 +05:30
export function getSortableDefaultOptions(options) {
2018-12-13 13:39:08 +05:30
const touchEnabled =
'ontouchstart' in window || (window.DocumentTouch && document instanceof DocumentTouch);
2017-08-17 22:00:37 +05:30
2020-05-24 23:13:21 +05:30
const defaultSortOptions = {
2022-06-21 17:19:12 +05:30
...defaultSortableOptions,
2019-09-30 21:07:59 +05:30
filter: '.no-drag',
2018-12-13 13:39:08 +05:30
delay: touchEnabled ? 100 : 0,
scrollSensitivity: touchEnabled ? 60 : 100,
2017-08-17 22:00:37 +05:30
scrollSpeed: 20,
2018-12-13 13:39:08 +05:30
onStart: sortableStart,
onEnd: sortableEnd,
2020-05-24 23:13:21 +05:30
};
2017-08-17 22:00:37 +05:30
2022-06-21 17:19:12 +05:30
return {
...defaultSortOptions,
...options,
};
2018-12-13 13:39:08 +05:30
}