Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FB-05 Node Editor UI - Working w/ function node #14

Merged
merged 19 commits into from
Apr 19, 2024
Merged
Changes from 1 commit
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b9ea0a3
Begin FB-05
JoshuaCWebDeveloper Apr 12, 2024
b0ce91f
Merge branch 'master' into fb-05-node-editor-ui
JoshuaCWebDeveloper Apr 12, 2024
91c5156
Move overriden methods first in engine.ts
JoshuaCWebDeveloper Apr 12, 2024
ac3c669
Move node drop calculations from flow-canvas to engine
JoshuaCWebDeveloper Apr 12, 2024
95d0cb1
Make connection between react-diagram and flow.slice state two-way
JoshuaCWebDeveloper Apr 17, 2024
6233e75
Finish implementing two-way state with flow-canvas and apply fixes
JoshuaCWebDeveloper Apr 18, 2024
f9f4447
Install and configure redux-persist for flow slice
JoshuaCWebDeveloper Apr 18, 2024
d66792f
Fix current errors in PR
JoshuaCWebDeveloper Apr 18, 2024
d6df467
Correct redux-persist import
JoshuaCWebDeveloper Apr 18, 2024
2eef906
Mock and copy various modules from the Node-RED client for node editing
JoshuaCWebDeveloper Apr 18, 2024
8581d64
Add dom-iterable ts lib
JoshuaCWebDeveloper Apr 18, 2024
52a3451
Import font-awesome
JoshuaCWebDeveloper Apr 18, 2024
40773c3
Store flow node instance in CustomNodeModel config
JoshuaCWebDeveloper Apr 18, 2024
3d414e4
Move Node-RED logic from modules/node to red/
JoshuaCWebDeveloper Apr 18, 2024
b8ea876
New <NodeEditor /> and builder slice for editing nodes
JoshuaCWebDeveloper Apr 18, 2024
1102b92
Write tests for builder
JoshuaCWebDeveloper Apr 18, 2024
e945b11
Fix existing tests
JoshuaCWebDeveloper Apr 19, 2024
148fa36
Write additional tests for flow.logic
JoshuaCWebDeveloper Apr 19, 2024
78186aa
Write additional tests for node redux module
JoshuaCWebDeveloper Apr 19, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Move overriden methods first in engine.ts
  • Loading branch information
JoshuaCWebDeveloper committed Apr 12, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 91c5156afd0935873ffc0ff25ed9e86b6c59dd79
56 changes: 28 additions & 28 deletions packages/flow-client/src/app/components/flow-canvas/engine.ts
Original file line number Diff line number Diff line change
@@ -48,34 +48,6 @@ export class CustomEngine extends DiagramEngine {
});
}

public increaseZoomLevel(event: WheelEvent): void {
const model = this.getModel();
if (model) {
const zoomFactor = 0.1; // Adjust this value based on your needs
const oldZoomLevel = model.getZoomLevel();
const newZoomLevel = Math.max(
oldZoomLevel + event.deltaY * -zoomFactor,
50
);

// Calculate the new offset
const boundingRect = (
event.currentTarget as Element
)?.getBoundingClientRect();
const clientX = event.clientX - boundingRect.left;
const clientY = event.clientY - boundingRect.top;
const deltaX = clientX - model.getOffsetX();
const deltaY = clientY - model.getOffsetY();
const zoomRatio = newZoomLevel / oldZoomLevel;
const newOffsetX = clientX - deltaX * zoomRatio;
const newOffsetY = clientY - deltaY * zoomRatio;

model.setZoomLevel(newZoomLevel);
model.setOffset(newOffsetX, newOffsetY);
this.repaintCanvas();
}
}

public override setModel(model: CustomDiagramModel): void {
const ret = super.setModel(model);

@@ -105,6 +77,34 @@ export class CustomEngine extends DiagramEngine {

return ret;
}

public increaseZoomLevel(event: WheelEvent): void {
const model = this.getModel();
if (model) {
const zoomFactor = 0.1; // Adjust this value based on your needs
const oldZoomLevel = model.getZoomLevel();
const newZoomLevel = Math.max(
oldZoomLevel + event.deltaY * -zoomFactor,
50
);

// Calculate the new offset
const boundingRect = (
event.currentTarget as Element
)?.getBoundingClientRect();
const clientX = event.clientX - boundingRect.left;
const clientY = event.clientY - boundingRect.top;
const deltaX = clientX - model.getOffsetX();
const deltaY = clientY - model.getOffsetY();
const zoomRatio = newZoomLevel / oldZoomLevel;
const newOffsetX = clientX - deltaX * zoomRatio;
const newOffsetY = clientY - deltaY * zoomRatio;

model.setZoomLevel(newZoomLevel);
model.setOffset(newOffsetX, newOffsetY);
this.repaintCanvas();
}
}
}

export const createEngine = (options = {}) => {