Giter VIP home page Giter VIP logo

Comments (12)

Bobface avatar Bobface commented on June 13, 2024 2

I just wanted to do the same thing as OP. Would be a great addition indeed!

from react-pan-zoom.

ajainarayanan avatar ajainarayanan commented on June 13, 2024 1

For anyone who is +1'ing this issue can you help review the pull request?

from react-pan-zoom.

mtpbzz avatar mtpbzz commented on June 13, 2024 1

Thanks for the PR. Looks good to me.

+1

from react-pan-zoom.

ajainarayanan avatar ajainarayanan commented on June 13, 2024

@malvf I see. Somethings for clarification

  • What is it that you wanted to do in your onPan function? The objective of the onPan function is to propagate the dx and dy value changes to the parent component using ReactPanZoom.
  • Right now there is only onPan callback (and not onZoom callback) because the dx and dy values are changed within the ReactPanZoom and onPan 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 onto ReactPanZoom.
    This is not the intended behavior. The pandx and pandy values are accepted only during initialization. Once initialized the component takes care of managing the dx and dy 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.

malvfr avatar malvfr commented on June 13, 2024

@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.

ajainarayanan avatar ajainarayanan commented on June 13, 2024

@malvf Hhmm this is not possible today. The cwrp life cycle function needs to be updated. PRs welcome!

from react-pan-zoom.

JoshuaSoileau avatar JoshuaSoileau commented on June 13, 2024

+1

from react-pan-zoom.

ajainarayanan avatar ajainarayanan commented on June 13, 2024

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.

foteros avatar foteros commented on June 13, 2024

+1

from react-pan-zoom.

awtyklo avatar awtyklo commented on June 13, 2024

+1

from react-pan-zoom.

anunnakian avatar anunnakian commented on June 13, 2024

+100

from react-pan-zoom.

ajainarayanan avatar ajainarayanan commented on June 13, 2024

Changes available as part of 0.0.4 version.

from react-pan-zoom.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.