Comments (12)
I just wanted to do the same thing as OP. Would be a great addition indeed!
from react-pan-zoom.
For anyone who is +1'ing this issue can you help review the pull request?
from react-pan-zoom.
Thanks for the PR. Looks good to me.
+1
from react-pan-zoom.
@malvf I see. Somethings for clarification
- What is it that you wanted to do in your
onPan
function? The objective of theonPan
function is to propagate the dx and dy value changes to the parent component usingReactPanZoom
. - Right now there is only
onPan
callback (and not onZoom callback) because the dx and dy values are changed within theReactPanZoom
andonPan
callback is the only way to propagate those values to the parent component. - You have a callback function for
onPan
prop. But you seem to be setting the dx and dy that is passed on to the function to your state which is eventually passed ontoReactPanZoom
.
This is not the intended behavior. Thepandx
andpandy
values are accepted only during initialization. Once initialized the component takes care of managing thedx
anddy
for you.
Can you provide more details on what is the objective of onPan
callback and why do you need to control the dx and dy from outside the component when it is already managed within it?
from react-pan-zoom.
@ajainarayanan Hello. So, my main goal is to have a function that resets the initial position and the zoom of the component that is nested in . So far, I managed to reset the initial zoom by setting the state as 1. I am trying to set the dx and the dy to 0 in the same function, but it is not working. I checked the transform-matrix property after the function was called and I found that the zoom's value is updated, although the dx and dy are not.
Unfortunately, I can't provide the full code. The function looks like this
``resetScale() {
this.setState({
zoom: 1,
dx:0,
dy:0
organogramData: cloneDeep(this.resetData)
});
}
My onPen callback it's exactly like yours in the code sandbox.
from react-pan-zoom.
@malvf Hhmm this is not possible today. The cwrp life cycle function needs to be updated. PRs welcome!
from react-pan-zoom.
+1
from react-pan-zoom.
Sorry for the super late response.
@malvf #7 Have added a fix as PR. Can you review and see if that works for you?
If all looks good will merge and will release a version.
from react-pan-zoom.
+1
from react-pan-zoom.
+1
from react-pan-zoom.
+100
from react-pan-zoom.
Changes available as part of 0.0.4 version.
from react-pan-zoom.
Related Issues (8)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from react-pan-zoom.