I am using swiperjs to make a slideshow section for dawn but it won't work...Any suggestions?

****
{%- if section.settings.image != blank -%} {{ section.settings.image.alt | escape }} {%- else -%} {{ 'image' | placeholder_svg_tag: 'placeholder-svg' }} {%- endif -%} {% for block in section.blocks %} {% case block.type %} {% when 'slide' %}
{{ block.settings.image | img_url: '2048x' | img_tag }}
{% endcase %} {% endfor %}

.swiper { width: 100%; height: 100%; }

{% schema %}

{
“name”: “Slideshow”,
“tag”: “section”,
“class”: “slideshow”,
“settings”: [
{
“type”: “text”,
“id”: “title”,
“label”: “Slideshow”
}
],
“blocks”: [
{
“name”: “Slide”,
“type”: “slide”,
“settings”: [
{
“type”: “image_picker”,
“id”: “image”,
“label”: “Image”
}
]
}
]
}

{% endschema %}

THANK U
Also here is a link to the swiperjs website if that helps : https://swiperjs.com/
:slightly_smiling_face: Ase

@gthegreat

Hi,

No need for external library for slideshow. Just copy paste the code - link the video description. No app needed as well. Buttons were updated

Use this one

https://www.youtube.com/watch?v=zGL2sBgBLoI&t=333s&ab_channel=Made4uo

Just put your Swiper initialisation code in the window load event and it should work.

{% javascript %}

window.addEventListener(‘load’, function() {

const swiper = new Swiper(“.swiper”, {
loop: true
});
});
{% endjavascript %}

Also our .swiper div should not have a parent div with using css flex display to avoid troubles.

Did you ever get Swiper.js to work in the Dawn theme? I’m trying to build a slider in Dawn and the markup comes out perfectly but Swiper isn’t working like it should.

I’m wondering if I should try a different solution?

Having the exact same issue as BenEight (above) - the script is being loaded correctly, the markup is valid, and Swiper is being initialized successfully, yet all placing all of my slides are being bundled into one slide.

Note: this happens even when I copy/paste the exact demo code from swiperjs.com, so I know it’s not an unclosed div or something.

Yes I did in Dawn theme no problem.

If you import Swiper CSS and JS in theme.liquid, if the parent div of your Swiper slider html code doesnt have a CSS flex position, and if you initialize a new Swiper instance in a JS load event, then it should work without any issues.

If you’re still facing issues, that means that something is wrong in your code, but not related to Shopify (check markup, differents swipers having the same classname, css, js code, etc.).

Hope I helped :slightly_smiling_face:

Got it - thanks BenjB!

Hi BenjB !
Are you part of Swiper team? Thanks so much! its such a great tool :slightly_smiling_face:
I suceeded in creating a customizable section with it! But my issue is that the script would require extra identificators when trying to use more than one swiper per page. I tried using {{section.id}}, but no luck… thought my JS level is quite basic, so maybe I didnt did it properly. Any Idea? Many, many thanks!