![]() I also added some CSS styling that is not described here, to limit the code to what is really necessary. ![]() However, you can also check the repo of my website to have a clearer view of how to do so. In this post, I tried to explain how to build a gallery with a simple example. # Make list of tidytuesday plots I want to show in the gallery The purpose of the function below is to download a plot for a specific week in a specific year in the repo containing my plots. Therefore, I created a function to make it as easy as possible for me to update the plots I want to display in the gallery. I have started participating to #tidytuesday this year, and the main reason I wanted to create a gallery was to display my favorite plots. If you haven’t set up GitHub Actions yet, you can check my previous post, or check my current GitHub Actions for this site. ![]() We also have to add magick and httr in the list of packages to install. We need to add fs::dir_copy("_gallery/img", "_site/_gallery/img") in GitHub Actions so that the images are found when the gallery is built. LightGallery(document.getElementById('lightgallery')) We can just copy-paste it in an R Markdown file. We now have to add the CSS and the JavaScript code. First, I create a function to resize a single image, and I will apply it to all the images I have: To automatically create these thumbnails, we can use the function image_resize() in the package magick. As we saw above, lightgallery.js also requires thumbnails in addition to full-size images. Keep in mind that Distill is (purposely) less flexible than other tools, such as Make the gallery with R Create thumbnailsįirst, store your (full-size) images in a folder, let’s say _gallery/img. NPM - NPM is a package manager for the JavaScript programming language. You can use any of the following method to download lightGallery. This post shows how to create a gallery on a Distill website. lightGallery is available on NPM, Yarn, Bower, CDNs, and GitHub. I found a workaround to that, I'll post it below since this was the only post about the topic I found and it can help someone in the future.Note: This post was originally written by Etienne Bacher and was copied here on see the original post here for a potentially updated version. if the gallery was opend while the page was still moving (smoothing), after closing, it jumped to the point where smoothing would end. What did work was setting smooth() to 0 in onBeforeOpen and setting it back to a desired value in Lightgallerys onBeforeClose hook. ScrollSmoother.paused(true) in Lightgallerys onBeforeOpen hook didn't help, it paused on position 0. This occurred only when opening Lightgallery for the first time (still not acceptable ). Before closing Lightgallery, the page jumped to the top and then scrolled back to the gallery container. I had sort of a similar problem in Nuxt3 with Lightgallery and ScrollSmoother. See the Pen PoBqpeO by akapowl ( on CodePenĪlso, if you update the lightGallery version you are using to at least version 2.5.0, apparently an option comes available that lets you prevent the resetting of the scroll-position altogether which would likely make the blocking of the scroll unneccessary to begin with. Here is a link to the events available with lightgallery: You will need to find the event working best for you, to toggle ScrollSmoother.paused() at the right time, if you want to disable the scroll while the gallery is open. I can see the issue described, but as Rodrigo mentioned, you will definitely need to update your GSAP version first and yes, it looks like it is a problem because you can scroll while the gallery is open, and when it closes it will move back to the position it was before opening (or something along those lines). ![]()
0 Comments
Leave a Reply. |