Answer the question
In order to leave comments, you need to log in
How to get rid of offset in Fancybox when scroll disappears?
Welcome all!
Sorry for the confusing thread title.
The crux of the issue is when you call a window in Fancybox, it is called to full screen, and the scroll disappears on the site itself. The problem is that when the scroll disappears, the entire site shifts to the right side by the size of this scroll. And it turns out not quite a pleasant picture, the site seems to be twitching.
How can this disease be cured?
Version: fancyBox v3.2.10
Answer the question
In order to leave comments, you need to log in
Add a right padding (for example) on the body when the modal opens.
Before opening the window, check: document.scrollHeight === document.offsetHeight
If equal, there is no scroll, everything is OK.
If not equal, the scroll should be shown, add, for example, to the body class, which has a higher priority than the fancybox class, which adds overflow:hidden.
Only it will be necessary to do preventDefault() to the scroll event for the duration of the fancybox display in this case
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question