Skip to content

Commit

Permalink
wip experimental dragula version
Browse files Browse the repository at this point in the history
  • Loading branch information
Niklas Kiefer committed Aug 1, 2023
1 parent 6bfb194 commit 63e313c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 27 deletions.
36 changes: 19 additions & 17 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/form-js-editor/assets/index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@use 'form-js-editor-base.css';
@use 'dragula/dist/dragula.css';
@use '@bpmn-io/draggle/dist/dragula.css';
@use '@bpmn-io/properties-panel/assets/properties-panel.css';
2 changes: 1 addition & 1 deletion packages/form-js-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
"@bpmn-io/properties-panel": "^3.0.0",
"array-move": "^3.0.1",
"big.js": "^6.2.1",
"dragula": "^3.7.3",
"@bpmn-io/draggle": "github:bpmn-io/draggle#prepare-fork",
"ids": "^1.0.0",
"min-dash": "^4.0.0",
"min-dom": "^4.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/form-js-editor/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ export default [
'preact/jsx-runtime',
'preact/hooks',
'preact/compat',
'dragula',
'@bpmn-o/dragula',
'@bpmn-io/form-js-viewer'
],
plugins: pgl([
Expand Down
17 changes: 12 additions & 5 deletions packages/form-js-editor/src/features/dragging/Dragging.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import dragula from 'dragula';
import dragula from '@bpmn-io/draggle';

import { set as setCursor } from '../../render/util/Cursor';

Expand Down Expand Up @@ -200,12 +200,17 @@ export default class Dragging {

const {
container,
direction,
mirrorContainer
} = options || {};

const dragulaInstance = dragula({
direction,
let dragulaOptions = {
direction: function(el, target) {
if (isRow(target)) {
return 'horizontal';
}

return 'vertical';
},
mirrorContainer,
isContainer(el) {
return container.some(cls => el.classList.contains(cls));
Expand Down Expand Up @@ -245,7 +250,9 @@ export default class Dragging {
},
slideFactorX: 10,
slideFactorY: 5
});
};

const dragulaInstance = dragula(dragulaOptions);

// bind life cycle events
dragulaInstance.on('drag', (element, source) => {
Expand Down
2 changes: 0 additions & 2 deletions packages/form-js-editor/src/render/components/FormEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,6 @@ export default function FormEditor(props) {
DROP_CONTAINER_VERTICAL_CLS,
DROP_CONTAINER_HORIZONTAL_CLS
],
direction: 'vertical',
mirrorContainer: formContainerRef.current
});

Expand All @@ -345,7 +344,6 @@ export default function FormEditor(props) {
DROP_CONTAINER_VERTICAL_CLS,
DROP_CONTAINER_HORIZONTAL_CLS
],
direction: 'vertical',
mirrorContainer: formContainerRef.current
});
setDrake(dragulaInstance);
Expand Down

0 comments on commit 63e313c

Please sign in to comment.