gitlab-org--gitlab-foss/app/assets/javascripts/sortable/utils.js

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

36 lines
824 B
JavaScript
Raw Normal View History

/* global DocumentTouch */
import { defaultSortableOptions, DRAG_CLASS } from './constants';
2018-02-19 14:06:16 -05:00
export function sortableStart() {
document.body.classList.add(DRAG_CLASS);
}
export function sortableEnd() {
document.body.classList.remove(DRAG_CLASS);
}
export function isDragging() {
return document.body.classList.contains(DRAG_CLASS);
}
2016-08-19 09:16:07 -04:00
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,
2017-04-10 19:52:46 -04:00
scrollSpeed: 20,
onStart: sortableStart,
onEnd: sortableEnd,
};
2017-04-10 19:52:46 -04:00
return {
...defaultSortOptions,
...options,
};
}