Closed pluspol closed 2 months ago
Looks like your using a very old version of this library
No, unfortunately not. We're using the latest version 4.3.9
.
Just looking at this again and I think your workaround, is the solution. I've added an example into the new version 5 API documentation and the troubleshooting guide.
https://iframe-resizer.com/api/parent/#onscroll https://iframe-resizer.com/troubleshooting/#srcolling-does-not-scroll-to-where-i-want-it
btw in v5 it is now slightly cleaner, as onScroll()
now also passes top
and left
const [iframe] = iframeResizer({
scrollCallback: ({ top }) => {
window.scrollTo({ top });
return false;
},
}, rawIframe);
Describe the bug In a special case scrolling the parent page leads to it jumping to the left.
This happens when:
margin 0 auto
)position: absolute; left: -100vw
)In this case
iframe-resizer´ calculates a scroll position like
300,400` which means it wants to scroll horizontally to 300px.In case of only a) and b)
iframe-resizer
too tries to scroll horizontally to 300px but nothing happens as the page isn't scrollable at all. Only when adding c) it's possible to scroll programmatically because of the wider element.This happens in Chrome and Firefox.
Workaround Luckily it's rather easy to override the scroll behaviour and disable horizontal scrolling to fix this issue:
To Reproduce Steps to reproduce the behavior: Is there a template for a Codesandbox that can easily be used to provide an example?
Here's the css of the parent page:
And the relevant markup for the parent page:
And the iframe is simply calling something like that:
Expected behavior The page shouldn't jump to the left but stay where it is.
Possible solutions
Screenshots If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):