Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Maintain scroll position on iframe reload #99

Open
samason opened this issue Jan 25, 2024 · 1 comment
Open

Maintain scroll position on iframe reload #99

samason opened this issue Jan 25, 2024 · 1 comment

Comments

@samason
Copy link

samason commented Jan 25, 2024

When the iframe pane is being used as a live preview, it would be ideal if on revision of a given content type that the iframe maintained its scroll position when reloaded.

@samason
Copy link
Author

samason commented Feb 2, 2024

Update on this in case anyone else is interested in the future:

I made an adjustment to the plugin to have this work locally that avoids any CORS issues. What I'm doing is instead of updating the src attribute of the iframe on reload, I'm using the fetch API on my source URL on reload, grabbing the HTML, and putting that into the srcdoc attribute. By updating the inner HTML of the iframe, you do not have to adjust your scroll position, and in order to do that without cross-origin issues, the HTML within the iframe must be inline.

I'm not making a PR for this since it's kind of hack-y and probably goes against most peoples use case but if there's interest I can share more details.

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

No branches or pull requests

1 participant