justhive / react-native-view-editor

A simple wrapper for being able to rotate, pan, and resize a child view or image with animations.
https://medium.com/@sscaff1/react-native-image-panning-zooming-832aef361c87#.dyvem0jr4
29 stars 16 forks source link

Posting is off #3

Closed sscaff1 closed 7 years ago

sscaff1 commented 8 years ago

Anyone want to take a hack at the ViewEditor and try to get the correct dimensions for the offset. It’s the one thing preventing us from getting proper image cropping working

offset: {
        x: (imageWidth - scale * imageWidth) / 2 + pan.x - subWidth,
        y: (imageHeight - scale * imageHeight) / 2 + pan.y - subHeight,
      },

So here is what works currently works:

  1. if you have the original image and try to post, the code as is works
  2. if you have the image zoomed in all the way the following code works
offset: {
        x: (imageWidth - scale * imageWidth) / 2 - pan.x - subWidth,
        y: (imageHeight - scale * imageHeight) / 2 - pan.y - subHeight,
      },

Notice all I did was change the sign on pan from positive to negative. Everything else does not work (you’ll get some black space in your cropped image. Any help is greatly appreciated. I’ve been looking at this all day and can’t figure out what factor is missing

sscaff1 commented 7 years ago

closed with latest commit.