[Hold for Payment - Sep 7th] Web - Attachments Preview - Zooming in the edges of an image will lead to white spaces
If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!
Action Performed:
- Open any chat
- Send an image as attachment
- Click on it in order to have larger preview
- Click on any edges in order to zoom it
Expected Result:
Picture is zoomed and picture fills whole preview dialogue
Actual Result:
Picture is zoomed, but there is a lot of white spaces
Workaround:
Can the user still use Expensify without this being fixed? Have you informed them of the workaround?
Platform:
Where is this issue occurring?
Web ✔️ iOS Android Desktop App Mobile Web
Version Number: 1.0.75-5 Logs: https://stackoverflow.com/c/expensify/questions/4856 Notes/Photos/Videos:
https://user-images.githubusercontent.com/43996225/124826208-9379ca00-df42-11eb-9566-11d31750b082.mp4

Expensify/Expensify Issue URL: https://github.com/Expensify/Expensify/issues/170015
Upwork job posting: Posted to Upwork: https://www.upwork.com/jobs/~014d8cadbc82d362b0
Triggered auto assignment to @francoisl (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.
Looks like this can be external
Triggered auto assignment to @NicMendonca (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.
What's the expected behavior here? Looks like the app kinda centers the image on the point where we're zooming in. https://github.com/Expensify/Expensify.cash/blob/f11d808f6358ba57ae02a1d392229dbd38491afd/src/components/ImageView/index.js#L95-L104 I feel like this is the correct behavior, but it also means that if we zoom on the edge there will be blank spots.
@rdjuric that question might be better suited for #expensify-open-source.
Triggered auto assignment to @roryabraham (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
What's the expected behavior here
My thinking here is that we should center the image on the point we're zooming in on, but if we're within a specific distance of any edge, then we'd shift the zoomed-in section accordingly. Something like this:

So if the point where we've clicked (the center of the zoom) is in any of the "gutters", then we'll shift the image horizontally and/or vertically as needed so that the zoomed-in size will fit within the bounds of the image.
Issue reproducible during KI retests
Hi @rdjuric! Based off @roryabraham's comment, are you keen to submit a proposal for this?
@NicMendonca Still researching this one 😅
Thanks for the picture, @roryabraham. So I think the behavior we want is what we have in the video below?
https://user-images.githubusercontent.com/53711423/125832688-777fcb5c-916b-4aff-9de5-7c274ad0c898.mov
It looks to me like it might not be working perfectly in the y-axis, but yeah that's prettymuch what I had in mind.
I have to reassign this to someone else while I'm OOO
Triggered auto assignment to @tgolen (Exported), see https://stackoverflow.com/c/expensify/questions/7972 for more details.
Issue reproducible during KI retests
@rdjuric Could you submit a proposal for this, please? It looks like the behavior in the video is pretty close to what's desired.
@rdjuric bump! Please let us know if you are still interested in submitting a proposal.
Issue reproducible during KI retests
@tgolen I'm back from OOO, so I can take this back now.
New Upwork job posting. Doubled the price since there hasn't been any proposals in a week: https://www.upwork.com/jobs/~0134dee8788c30ccc5
@roryabraham I looked at this a bit more and looks like there're more issues at play:
- An image that is smaller than the size of the viewport isn't being zoomed
- The zoom is done on the
Viewthat surrounds the image, so it doesn't correctly give a point in the image to zoom in.
Point (1) happens because we're "zooming" by increasing the height/width of our Image component to 250% while using resizeMode="center", this will only increase the size of the image if it was being scaled down by the resize - i.e, only when the image isn't bigger than the Image component.
Assuming that we fix (1), I don't think it's possible to "not show any blank spaces around the image" if our zoom is constant (like the 2.5x we use here) and our AttachmentModal is bigger than the image. Imagine that we have an image with size 100px x 100px, we zoom it so it's 250px x 250px. If our AttachmentModal (which has a size based on the window dimension) is bigger than 250px x 250px we're necessarily going to have white spaces around the image after zooming.
If we really don't want white spaces around the image, I think we must either:
- Make the size of our
AttachmentModalequal to the size of the attachment it's rendering - Change our zoom to always make the image fill the viewport. This would lead to different levels of zoom depending on the original size of the image.