Closed JayEn84 closed 11 months ago
You can sort of already do this via the onScroll
event on the parent page.
https://github.com/davidjbradshaw/iframe-resizer/blob/master/docs/parent_page/events.md#onscroll
onScroll: ({x, y}) => {
window.scroll(x, y - 50)
return false
}
Yes, that's a possible solution. What we do instead is this:
parentIFrame.scrollToOffset(0, anchorScrollTop - 60);
However, I think the optional argument would make it a little easier, which is why I thought I'd provide you with the suggestion over here. :)
Guess it might be nice to be able to return updated x, y values here, rather than have to implement it yourself to get the offset.
onScroll: ({x, y}) => { x, y: y -50 }
Happy to take a PR if you want to make one to do this.
I’m trying not to add more options, as this is already complex enough. But a new return type to an event would have less impact on the API surface.
We use the moveToAnchor method to scroll to a specific target within the iFrame. Works like a charm. Now we have a parent site that has a fixed header with a height of approx. 50px. When using the moveToAnchor method, the target is directly behind the fixed header.
An optional offset argument in the moveToAnchorMethod would be an easy way to take fixed headers into account.