Closed iacebedoherrera closed 1 month ago
(edited OP to format the code properly)
I'm not able to reproduce the issue. Can you share the carousel component?
I'm not able to reproduce the issue. Can you share the carousel component?
Thank you for answering! This is the component that I'm using, but if you know of any other carousel that I can use, I would be happy to know.
def photos_carousel() -> rx.Component:
return rx.flex(
rx.html(
"""
<div class="carousel-container">
<div id="slideshow-container" class="slideshow-container"></div>
<a class="prev" onclick="plusSlides(-1)">❮</a>
<a class="next" onclick="plusSlides(1)">❯</a>
</div>
"""
),
rx.script(
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"
),
rx.script(
"""
function carousel() {
var pathname = window.location.pathname;
var backendUrl = "http://localhost:8000";
var rutaImagenes = backendUrl + pathname.replace('/products', '/images');
console.log(rutaImagenes);
$.get(rutaImagenes, function(data) {
if (data.image_paths) {
var imagePaths = data.image_paths;
var slideshowContainer = document.getElementById("slideshow-container");
slideshowContainer.innerHTML = ""; // Limpiar el contenedor antes de agregar imágenes nuevas
imagePaths.forEach(function(path) {
var adjustedPath = '/products/' + path;
var slide = document.createElement("div");
slide.className = "mySlides fade";
var img = document.createElement("img");
img.src = adjustedPath;
img.style.width = "100%";
slide.appendChild(img);
slideshowContainer.appendChild(slide);
});
var slideIndex = 1;
showSlides(slideIndex);
window.plusSlides = function(n) {
showSlides(slideIndex += n);
};
function showSlides(n) {
var i;
var slides = document.getElementsByClassName("mySlides");
if (n > slides.length) {slideIndex = 1}
if (n < 1) {slideIndex = slides.length}
for (i = 0; i < slides.length; i++) {
slides[i].style.display = "none";
}
slides[slideIndex-1].style.display = "block";
}
} else {
console.log("No image paths found in response");
}
}).fail(function(jqXHR, textStatus, errorThrown) {
console.log("Error fetching images: ", textStatus, errorThrown);
});
}
"""
)
)
You can try with this reflex custom component https://github.com/picklelo/reflex-carousel
If you encounter any issues, feel free to post in the ‘help’ channel on our Discord
Thank you so much, it helps me a lot with the image carousel and now it is shown correctly
Describe the bug When I render an image carousel in desktop view, the carousel is shown correctly. But when I use rx.mobile_only, the carousel doesn´t appear if the screen width is lower than 992px.
To Reproduce
And these are the functions that are called:
def product_detail_for_mobile() -> rx.Component: return rx.flex( photos_carousel(), product_info(), direction="column", align="center", padding_top=Size.BIG.value, padding_bottom=Size.BIG.value, width="90%" )