Skip to content

Commit

Permalink
fix: improve drag preview alignment
Browse files Browse the repository at this point in the history
Related to #596
  • Loading branch information
Skaiir committed Mar 7, 2024
1 parent 495efb0 commit 8a46b7a
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 30 deletions.
35 changes: 11 additions & 24 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 '@bpmn-io/draggle/dist/dragula.css';
@use '@bpmn-io/draggle/dist/draggle.css';
@use '@bpmn-io/properties-panel/dist/assets/properties-panel.css';
5 changes: 3 additions & 2 deletions packages/form-js-editor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
},
"./dist/assets/form-js-editor.css": "./dist/assets/form-js-editor.css",
"./dist/assets/form-js-editor-base.css": "./dist/assets/form-js-editor-base.css",
"./dist/assets/dragula.css": "./dist/assets/dragula.css",
"./dist/assets/draggle.css": "./dist/assets/draggle.css",
"./dist/assets/dragula.css": "./dist/assets/draggle.css",
"./dist/assets/properties-panel.css": "./dist/assets/properties-panel.css",
"./package.json": "./package.json"
},
Expand Down Expand Up @@ -46,7 +47,7 @@
"url": "https://github.com/bpmn-io"
},
"dependencies": {
"@bpmn-io/draggle": "^4.0.0",
"@bpmn-io/draggle": "^4.1.0",
"@bpmn-io/form-js-viewer": "^1.7.3",
"@bpmn-io/properties-panel": "^3.18.1",
"array-move": "^3.0.1",
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 @@ -69,7 +69,7 @@ export default [
copy({
targets: [
{ src: 'assets/form-js-editor-base.css', dest: 'dist/assets' },
{ src: '../../node_modules/@bpmn-io/draggle/dist/dragula.css', dest: 'dist/assets' },
{ src: '../../node_modules/@bpmn-io/draggle/dist/draggle.css', dest: 'dist/assets' },
{ src: '../../node_modules/@bpmn-io/properties-panel/dist/assets/properties-panel.css', dest: 'dist/assets' }
]
})
Expand Down
35 changes: 35 additions & 0 deletions packages/form-js-editor/src/features/dragging/Dragging.js
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,41 @@ export class Dragging {

return !target.classList.contains(DRAG_NO_DROP_CLS);
},

transformOffset: (offset, event, element) => {

if (element.classList.contains(DRAG_ROW_MOVE_CLS)) {

const rowOffset = {
x: -5,
y: -60
};

return {
left: event.clientX + rowOffset.x,
top: event.clientY + rowOffset.y
};

}

if (element.classList.contains(DRAG_MOVE_CLS)) {

const iconOffset = {
x: -5,
y: -15
};

return {
left: event.clientX + iconOffset.x,
top: event.clientY + iconOffset.y
};

}

return offset;

},

slideFactorX: 10,
slideFactorY: 5
};
Expand Down
2 changes: 1 addition & 1 deletion packages/form-js-editor/test/spec/FormEditor.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -988,7 +988,7 @@ describe('FormEditor', function() {
});


it('should create and select new form field', async function() {
it.only('should create and select new form field', async function() {

Check failure on line 991 in packages/form-js-editor/test/spec/FormEditor.spec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04, 20)

Unexpected exclusive mocha test

Check failure on line 991 in packages/form-js-editor/test/spec/FormEditor.spec.js

View workflow job for this annotation

GitHub Actions / Build (ubuntu-20.04, 20)

Unexpected exclusive mocha test

// given
let dragulaCreated = false;
Expand Down
3 changes: 2 additions & 1 deletion packages/form-js/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
},
"./dist/assets/form-js.css": "./dist/assets/form-js.css",
"./dist/assets/form-js-base.css": "./dist/assets/form-js-base.css",
"./dist/assets/dragula.css": "./dist/assets/dragula.css",
"./dist/assets/draggle.css": "./dist/assets/draggle.css",
"./dist/assets/dragula.css": "./dist/assets/draggle.css",
"./dist/assets/flatpickr/light.css": "./dist/assets/flatpickr/light.css",
"./dist/assets/properties-panel.css": "./dist/assets/properties-panel.css",
"./dist/assets/form-js-editor.css": "./dist/assets/form-js-editor.css",
Expand Down

0 comments on commit 8a46b7a

Please sign in to comment.