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

Scrollytelling sticky overlay with a R htmlwidget chart #1

Open
d-qn opened this issue Mar 25, 2023 · 2 comments
Open

Scrollytelling sticky overlay with a R htmlwidget chart #1

d-qn opened this issue Mar 25, 2023 · 2 comments

Comments

@d-qn
Copy link

d-qn commented Mar 25, 2023

Thanks for sharing your experiments ! I am very interested to have scrollytelling with Quarto, but have a R htmlwidget chart as the sticky zone. Do you think it possible and easily achievable in Quarto ? I had a quick look at Scrolloma.js, but I can't say I understand it yet

@jimjam-slam
Copy link
Owner

jimjam-slam commented Mar 26, 2023

Hi @d-qn! It probably depends on what you want the sticky element to do. If you just want it to be there while your text scrolls past, it'll be enough to position and stick the htmlwidget with CSS. If you want it to update or change, I think that's going to be difficult, because you can't have any R code re-run on scroll (unless you're either using Shiny or WebR).

One alternative could be to have three or four different maps and have each show or hide based on scroll position. You'd do this like the purple boxes example, attaching or removing a CSS class to each map and using display: none to remove the ones you aren't showing.

Otherwise, you could check out the {rolldown} package, which is designed to do this with R Markdown. Or, in Quarto, using Observable JS or Sverto to build a visual that can respond to the scroll changes :)

@d-qn
Copy link
Author

d-qn commented Mar 27, 2023

Hi James. Thank you for this detailed answer 🙏🏼 ! I was only aiming for the R chart/htmlwidget to be there as a sticky element, I wasn't even considering to animate it on scroll. In case you are planning to pursue your experiments, that would be awesome if you could show how to do stick such element with CSS. Might give it a try otherwise, but I can't really make sense of Scrolloma.js yet.

Thanks for the other resources. I saw the {rolldown} package, but because there hasn't been any activity for a while on that repo, I was wondering if your approach is somewhat better or more uptodate

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

2 participants