vue-awesome-swiper icon indicating copy to clipboard operation
vue-awesome-swiper copied to clipboard

Responsive slides

Open VladStepanov opened this issue 6 years ago • 8 comments

I have a trouble with mobile slider, i want slide to be 100% width, but it sets huge width in px. https://imgur.com/My8QBJL

also if i scroll to right, i will see next slides https://imgur.com/YFsJfUw

VladStepanov avatar Jul 22 '19 15:07 VladStepanov

Hi, are there solutions for this issue? Thanks

giuseppeangri avatar Nov 20 '19 09:11 giuseppeangri

Im stucked at the same problem

CavalcanteLeo avatar Apr 03 '20 02:04 CavalcanteLeo

Use breakpoints with Swiper.

API breakpoints example code

surmon-china avatar Apr 03 '20 02:04 surmon-china

you can use ->

breakpoints: { 1024: { slidesPerView: 4, spaceBetween: 40 }, 768: { slidesPerView: 3, spaceBetween: 30 }, 640: { slidesPerView: 2, spaceBetween: 20 }, 320: { slidesPerView: 1, spaceBetween: 10 } }

mptmadhushan avatar Jul 13 '20 17:07 mptmadhushan

Please responses aren't helping that much, issue still happening on my current project.

<template>
  <div class="block w-full">
    <div v-swiper:gallerySwiper="galleryOptions">
      <div class="swiper-wrapper">
        <div
          class="swiper-slide"
          v-for="(image, index) in slides"
          :key="index">
          <img
            :src="image.source"
            :alt="image.alt">
        </div>
      </div>
      <div class="swiper-button-prev"></div>
      <div class="swiper-button-next"></div>
    </div>
  </div>
</template>
<script>
export default {
  props: {
    slides: {
      type: Array,
      default: () => ([]),
      required: true
    }
  },

  data: () => ({
    galleryOptions: {
      loop: true,
      spaceBetween: 15,
      slidesPerView: '3',
      navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev'
      }
    }
  })
}
</script>

Is causing the page to grow extra large width when switching to mobile view.

TakCastel avatar Sep 17 '20 15:09 TakCastel

  1. Use an observer to observe parent size change (via observer API or other framework tools)
  2. on resize, emit resize event
<template>
      <swiper ref='mySwiper' :onParentResize='onResize'>
               ... omitted for brievity
      </swiper>
</template>
<script lang='ts'>
   onResize() {
        Vue.nextTick(() => {
            this.$refs['mySwiper'].$swiper.emit('resize');
        })
   }
</script>

Note that you have to implement the onParentResize directive yourselves!

kirinnee avatar Oct 12 '20 10:10 kirinnee

@surmon-china the demo is wrong too when resize to mobile screen https://ibb.co/cDnbcT6 By the way, see my issue #763

tungdz6518 avatar Jan 23 '21 03:01 tungdz6518

Having issue with the lowest breakpoint which is 320px, instead of showing 1 slide, it's showing 2 slides even after putting a width of 100%, anyone experiencing this?

Favalcodes avatar Sep 05 '21 09:09 Favalcodes