Skip to content
This repository has been archived by the owner on Feb 23, 2023. It is now read-only.

Opening/closing causes body to jump 1px #1910

Closed
Pixelous opened this issue Apr 12, 2018 · 1 comment
Closed

Opening/closing causes body to jump 1px #1910

Pixelous opened this issue Apr 12, 2018 · 1 comment

Comments

@Pixelous
Copy link

Hi @fancyapps opening/closing causes body to jump 1px.

Body has margin right 16px but should has 17px.

You can see it on your demo. Tested on Windows, Chrome.

Looks this is because of small element width and height (50px). Make it larger (100px) and you will notice margin right for compensate-for-scrollbar class will be not 16px but 17px then.

In jquery.fancybox.js on line 538 find

$scrollDiv = $('<div style="width:50px;height:50px;overflow:scroll;" />').appendTo("body");
and replace it with

$scrollDiv = $('<div style="width:100px;height:100px;overflow:scroll;" />').appendTo("body");

Can you please fix this?

@fancyapps
Copy link
Owner

fancyapps commented Apr 12, 2018

Hi!

Thanks for noticing, reporting and providing useful fix! This has been included in the last release.

While it is still not perfect solution, I think it is good enough. You see, the problem is that the vertical scrollbar width of the body element is different from the other elements on the page. And sometimes this value is not round integer. In early versions the script calculated that precisely, but that causes some lag for heavy pages (e.g., pages with many dom elements) and therefore it was simplified.

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

2 participants