-
Notifications
You must be signed in to change notification settings - Fork 2.7k
[MM-29881] Add ability to zoom in/out on PDFs #5361
Conversation
Test server destroyed |
Creating a new SpinWick test server using Mattermost Cloud. |
Mattermost test server created! 🎉 Access here: https://mattermost-webapp-pr-5361.test.mattermost.cloud
|
This is sweet! Adding @andrewbrown00 to do a UX review |
New commit detected. SpinWick will upgrade if the updated docker image is available. |
Mattermost test server updated with git commit Access here: https://mattermost-webapp-pr-5361.test.mattermost.cloud |
Noticing some errors in the console when you try to click the zoom in or out button very quickly. Occurs more frequently with more complex PDFs:
I'm guessing this is because the previous render hasn't finished yet when a new render is called? |
components/view_image/view_image.jsx
Outdated
<div> | ||
<div | ||
className='modal-zoom-in' | ||
onClick={this.handleZoomIn} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps a possible solution is using debounce
from lodash to set a min time between clicks to call the function as well as a max wait time to call. Something like:
onClick={debounce(this.handleZoomIn, 300, {maxWait: 300})}
However, the errors I mentioned in my comment still exists (at a lower rate) for larger file sized PDFs, so I'm not sure if this is the best solution.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @shred86 thanks for the awesome contribution 🎉
I completed the UX review and added my feedback and recommended improvements below.
Items to resolve
-
Scrolling no longer shows any additional pages, I only see the first page. This is a regression and should align with the existing behavior.
-
Don't maintain the last zoomed size when closing, always reset the preview size back to the default when closing and reopening the preview modal.
-
Make sure the
Get a public link
logic still works, the link is missing in this PR.
Current | This PR |
---|---|
Recommend improvements
-
Let's change the style of the
+
and-
icons to use themattermost icons
font. This should be available in the repo. If not, let me know and I'll get you what you need. -
Let's add a
Fit to width
andReset zoom
toggle button in between the icon buttons. Check out Gmail as a great reference for the expected behavior when toggling between the states. -
The
Zoom out
button should be disabled and dimmed when a user clicks to open the preview modal. Let's avoid letting users zooming below the default preview size. Also, clickingzoom out
should stop zooming after the preview reaches the default (size when first opened) size. -
The
Zoom in
button should be disabled and dimmed when a user hits a max size based on allowing the user to click the+
button 6 times; we may need to adjust this + or - a few clicks. -
Let's update the style of the
Download to read more pages
button to be more prominent and align with our new style updates.
Prototype
I've created a fully interactive prototype to show the behavior and styles when clicking the zoom
icons.
Note, tapping the space bar on the first screen will (fake) scroll to last page. From the last screen, just click on the document to reset the prototype back to the first page.
Also, as I previously mentioned, the Gmail preview modal is a great reference for the expected functional behavior/timing when zooming in and out.
Thanks for the feedback! Items to resolve
Recommend improvements
This will likely take me some time but I'll get as far as I can. I'm hoping someone will have some tips on how to resolve this issue. |
Hi @shred86 let us know if you need some help addressing the items identified |
@andrewbrown00 can you help answer this? |
Hi @shred86, are you able to see the fonts in this directory? You can copy and paste the glyph or
|
@andrewbrown00 I'm not sure which directory you're referring to. I'm looking at the fonts/mattermosticons on this repository. Can you provide me a link to the directory you have pictured of the mattermost icons? Also, do I need to create a new jsx file for these icons individually in the components/widgets/icons directory or can I just use this mattermosticon font type directly? Unfortunately styling is a weak area for me so I may need some assistance on this one. |
Just made a commit with where I'm at. I've made most of the changes requested from the UX review but here's what's left:
I should be able to take care of the first one if I can figure out how to access the mattermost icons. The second option I'll need some feedback/assistance. I'd recommend the last two we save for another PR unless someone else wants to work on it. |
@asaadmahmood will you help @shred86 to make sure we are using the
|
@shred86 The icons are already there, you can find all the icons this directory. There you would be able to see the class names of all the icons. |
Appreciate the help! Some remaining issues:
|
e595dc9
to
f5b70f1
Compare
@shred86 Pushed and fixed. |
Creating a new SpinWick test server using Mattermost Cloud. |
Mattermost test server created! 🎉 Access here: https://mattermost-webapp-pr-5361.test.mattermost.cloud
|
Thank you @shred86 |
Test server destroyed |
@amyblais I'll create a Jira Ticket and link here shortly. |
Thanks you very much for this amazing contribution @shred86 🚀 🎉 |
Co-authored-by: Asaad Mahmood <[email protected]> Co-authored-by: Ben Schumacher <[email protected]>
Co-authored-by: Asaad Mahmood <[email protected]> Co-authored-by: Ben Schumacher <[email protected]>
Summary
Adds the ability to zoom in and out on PDFs. This required a change in how
ViewImageModal
is initially rendered. Instead of displaying based on the size of the PDF (or other supported media), it now opens toheight: 90vh
andwidth: 90:vw
. This was to prevent the modal from continuously expanding and shrinking when the zoom in/out functionality was used. Additional notes:scale
state inViewImageModal
so it can be applied to other types of media if desired.getViewport
from PDF js. The reason I took this approach was to provide a higher quality PDF when you zoom in. There's some PDFs that if you try to zoom using the initial render size/scale factor, it's very blurry and hard to read. The other implementation option is to just render the PDF to a higher quality initially, then use pure CSS for the zoom in/out functionality. This would make it easier to implement with other media types (I think).One minor "issue" where the horizontal scroll bar doesn't show up unless you scroll all the way to the bottom. I've spent the afternoon trying to figure this one out but will continue to investigate. I'm assuming it's just a styling issue.
Ticket Link
https://mattermost.atlassian.net/browse/MM-29881
Related Pull Requests
N/A
Screenshots
Video Clip: https://imgur.com/3JieFTx