Skip to content
This repository was archived by the owner on Aug 21, 2019. It is now read-only.

Image is not truly full screen in full screen mode. #37

Open
tanbox opened this issue Apr 24, 2016 · 1 comment
Open

Image is not truly full screen in full screen mode. #37

tanbox opened this issue Apr 24, 2016 · 1 comment

Comments

@tanbox
Copy link

tanbox commented Apr 24, 2016

Some of my images load with small top/bottom or side margins. You can see this behavior in your own full screen example. Depending on the browser's window size sometimes you don’t see this issue right away. If that’s the case then try resizing the window slowly and you will see these margins appear/disappear depending on the window's size. If you stop resizing just at the right time you may see margins on all four sides. Is there a way to get rid of them? Thank you.

@tanbox
Copy link
Author

tanbox commented Apr 26, 2016

I figured this out and I am posting it in case someone else has the same issue. It is caused by the “scaleToFit” variable being rounded to just 2 decimal points. That left room for visible margins. I changed it to 4 decimal points and the margins aren’t visible anymore.

The fix directly in e-smart-zoom-jquery.min.js:
Find line: var f=Math.min(Math.min(a.width/r.width,a.height/r.height),1).toFixed(2);
Replace with: var f=Math.min(Math.min(a.width/r.width,a.height/r.height),1).toFixed(4);

To fix in e-smart-zoom-jquery.js:
Find line: var scaleToFit = Math.min(Math.min(containerRect.width/originalSize.width, containerRect.height/originalSize.height), 1).toFixed(2); // scale to use to include the target into containerRect
Replace with: var scaleToFit = Math.min(Math.min(containerRect.width/originalSize.width, containerRect.height/originalSize.height), 1).toFixed(4); // scale to use to include the target into containerRect

Special thanks to the creator of this plugin for it being so well commented and having variable names that make since to the novices. Because of that I was able to figure out what was happening without prior knowledge of JavaScript and very little other programming skills.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant