diff options
Diffstat (limited to 'app/assets/javascripts/sortable/utils.js')
-rw-r--r-- | app/assets/javascripts/sortable/utils.js | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/app/assets/javascripts/sortable/utils.js b/app/assets/javascripts/sortable/utils.js new file mode 100644 index 00000000000..c2c8fb03b58 --- /dev/null +++ b/app/assets/javascripts/sortable/utils.js @@ -0,0 +1,31 @@ +/* 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, + }; +} |