Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2022-04-07 21:08:29 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2022-04-07 21:08:29 +0300
commitc2bdb9d02768a61bee7560113f4d4c83dc91338e (patch)
treee242f8d39df80ec39a59eb73ad96ee389c8a4d41 /app/assets/javascripts/sortable
parentfe4751154c331e35c0e6575a3aedc02b210a1c63 (diff)
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'app/assets/javascripts/sortable')
-rw-r--r--app/assets/javascripts/sortable/constants.js19
-rw-r--r--app/assets/javascripts/sortable/sortable_config.js8
-rw-r--r--app/assets/javascripts/sortable/utils.js31
3 files changed, 50 insertions, 8 deletions
diff --git a/app/assets/javascripts/sortable/constants.js b/app/assets/javascripts/sortable/constants.js
new file mode 100644
index 00000000000..7fddac00ab2
--- /dev/null
+++ b/app/assets/javascripts/sortable/constants.js
@@ -0,0 +1,19 @@
+/**
+ * Default config options for sortablejs.
+ * @type {object}
+ *
+ * @example
+ * import Sortable from 'sortablejs';
+ *
+ * const sortable = Sortable.create(el, {
+ * ...defaultSortableOptions,
+ * });
+ */
+export const defaultSortableOptions = {
+ animation: 200,
+ forceFallback: true,
+ fallbackClass: 'is-dragging',
+ fallbackOnBody: true,
+ ghostClass: 'is-ghost',
+ fallbackTolerance: 1,
+};
diff --git a/app/assets/javascripts/sortable/sortable_config.js b/app/assets/javascripts/sortable/sortable_config.js
deleted file mode 100644
index a4c4cb7f101..00000000000
--- a/app/assets/javascripts/sortable/sortable_config.js
+++ /dev/null
@@ -1,8 +0,0 @@
-export default {
- animation: 200,
- forceFallback: true,
- fallbackClass: 'is-dragging',
- fallbackOnBody: true,
- ghostClass: 'is-ghost',
- fallbackTolerance: 1,
-};
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,
+ };
+}