Skip to content

Slides: add elements outside .swiper-wrapper #15330

@tricki

Description

@tricki

Support Question

I'm trying to add a parallax background to a slider (based on total slider progress). This requires an element that is a direct child of .swiper-container (outside .swiper-wrapper).

I thought I could just add another slot to Slides at the correct position. But that doesn't work because a <slot> element is inserted which doesn't mirror the original attributes. And Swiper only checks for direct children of .swiper-container.

image

Relevant Swiper code ($el === $('.swiper-container')):

$el.children('[data-swiper-parallax], [data-swiper-parallax-x], [data-swiper-parallax-y]')
  .each((index, el) => {
    swiper.parallax.setTransform(el, progress);
  });

Source: https://github.com/nolimits4web/swiper/blob/master/src/components/parallax/parallax.js#L56

Is there a way I can insert an element into the Shadow DOM without a <slot> element being inserted? Or is there a way to mirror the attributes of the "slotted" element (<div slot="container" data-swiper-parallax="-23%"/>) to the <slot> element?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions