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

The inner canvas goes out of the viewport #224

Open
Kousal opened this issue Dec 30, 2020 · 1 comment
Open

The inner canvas goes out of the viewport #224

Kousal opened this issue Dec 30, 2020 · 1 comment

Comments

@Kousal
Copy link

Kousal commented Dec 30, 2020

@MrBlenny This project is great and gives a lot of useful features.
I face difficulty when I use custom Inner and Outer canvas. Main purpose of the custom canvas is that I don't want my canvas to be too large, I want the canvas within my window viewport. I use the below Custom canvas componets.

const CanvasInnerCustom = styled.divposition: relative; left: 0px; top: 0px; outline: 1px dashed rgba(0,0,0,0.1); width: 80vw; height: 70vh; overflow: scroll; cursor: not-allowed; as any

const CanvasOuterCustom = styled.divposition: relative; background-size: 10px 10px; background-color: #D3D3D3; background-image: linear-gradient(90deg,hsla(0,0%,100%,.1) 1px,transparent 0), linear-gradient(180deg,hsla(0,0%,100%,.1) 1px,transparent 0); width: 80vw; height:70vh; overflow: scroll; cursor: not-allowed; as any

To begin with it works perfect. However, when I zoom in and zoom our repeatedly, my inner canvas gets displaced and moves out of my view.

image

Can someone suggest how to achieve this ? or is it a new features that is not achievable with the current version of react-flow-chart

@NaeemHHassan
Copy link

@Kousal override callback onZoomCanvas as
onZoomCanvas: ({ config, data }) => { if (data.scale < config.zoom.minScale) return setState({ ...state }); const chart = { ...state }; chart.offset = getOffset(config, { x: data.positionX, y: data.positionY }) chart.scale = data.scale setState(chart); }
I've solved this issue by doing this. Hope so it helps.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants