question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Scrollbar not working

See original GitHub issue

中文用户注意:

  1. 尽量用英文描述你的 Issue,你的问题是面向世界的
  2. 不要把内容堆彻在标题上,逻辑清晰地写在内容区
  3. 贴代码要提前格式化好,有颜色高亮那种,贴文本,不要贴图片
  4. 提问题前,务必仔细阅读 README.md;在已关闭的问题中寻找与自身相关的问题,90% 的可能它已经被解决

BUG REPORT TEMPLATE

Vue.js version and component version

Vue.js v2.6.11 Swiper 6.0.1 Vue Awesome Swiper 4.1.1

Reproduction Link

https://jsfiddle.net/u42arhtg/2/

Steps to reproduce

add <div class="swiper-scrollbar" slot="scrollbar"></div> add

scrollbar: {
          el: '.swiper-scrollbar',
          draggable: true,
          hide: false,
        },

to the swiperOptions Object

What is Expected?

There should be an scrollbar which allows the user to drag the slider and indicate how many items are left

this is an example:

<div class="c-slider__scrollbar swiper-scrollbar">
    <div class="swiper-scrollbar-drag" style="transform: translate3d(0px, 0px, 0px); transition-duration: 0ms; width: 572.028px;">    </div>
</div>

What is actually happening?

the Scrollbar gets rendered but is not working

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:8
  • Comments:5

github_iconTop GitHub Comments

4reactions
mortensassicommented, Nov 12, 2020

I found that for many cases you don’t need this wrapper in order to get swiper to work - I don’t want to discredit the developer or maintainer but i am a fan of keeping stuff easy and simple. Now since swiper is offering a highly modular api you can just import all you need in your vue component and easy init when its mounted() @Ic3m4n34 i show you my code for a slider component which shows teaser of different types (“News” and “Work”)

<template>
  <div
    class="c-slider c-slider--fixed c-slider--start swiper-container"
    :class="{ 'is-ready': sliderReady }"
  >
    <div class="c-slider__wrapper swiper-wrapper">
      <SliderItem
        v-for="(entry, entryIndex) in data"
        :key="entryIndex"
        :active="currentIndex === entryIndex"
        :data="entry"
        class="c-slider__item swiper-slide"
      />
    </div>
    <div class="swiper-pagination c-slider__pagination"></div>
  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { Swiper, EffectFade, Autoplay, Pagination } from 'swiper'
Swiper.use([EffectFade, Autoplay, Pagination])

export default {
  name: 'Slider',
  props: {
    data: {
      type: Array,
      default: null,
    },
  },

  data() {
    const vm = this
    return {
      currentIndex: 0,
      nextSlideType: '',
      slider: null,
      options: {
        effect: 'fade',
        autoplay: {
          delay: 8000,
        },
        pagination: {
          el: '.c-slider__pagination',
          clickable: true,
        },
        loop: true,
        on: {
          slideChange() {
            const slides = vm.data.length - 1
            const index = this.realIndex
            const slideType = (i) => vm.data[i].type
            const currentPost = vm.data[this.realIndex]

            vm.currentIndex = this.realIndex

            vm.nextSlideType =
              index === slides ? slideType(0) : slideType(index + 1)

            vm.$store.dispatch('aside/setBottomContent', {
              post: currentPost,
              type: 'tease',
            })
          },
        },
      },
    }
  },

  computed: {
    ...mapGetters({ sliderReady: 'site/sliderReady' }),
  },

  mounted() {
    this.$store.dispatch('site/sliderImagesCount', this.data.length)
    this.slider = new Swiper('.c-slider', this.options)
    this.slider.init()
  },

  beforeDestroy() {
    this.$store.dispatch('site/resetImages')
    this.slider.autoplay.stop()
    this.$store.dispatch('aside/setBottomContent', null)
    this.$store.dispatch('imageClone/resetClone')
    this.slider.destroy()
  }
}
</script>

<style lang="scss" src="@/assets/scss/components/_slider.scss"></style>

I think this code will get you an better idea of what is possible with just the core plugin

0reactions
AndrewBogdanovTSScommented, Nov 16, 2020

@mortensassi I agree with you. Since vue-awesome-swiper still doesn’t have proper Swiper 6 support - I would also recommend to use wrapperless lib whenever possible, basically in 99% of cases you can use a Swiper.js itself

Read more comments on GitHub >

github_iconTop Results From Across the Web

html - Scrollbar not working - Stack Overflow
The problem is that you specified: height:auto;. under the .my1 rule, so the div will expand in height as much as needed to...
Read more >
Scrollbar not working in windows 10 applications
1. Press the Windows button + X on your keyboard, a mini dialogue box will appear. · 2. Choose Command Prompt (Admin). ·...
Read more >
How to Fix Mouse Scroll Not Working on Windows 11/10
How to Fix Mouse Scroll Not Working on Windows 11/10 · Disconnect and Reconnect the Mouse to Your PC · Replace Your Wireless...
Read more >
::-webkit-scrollbar - CSS: Cascading Style Sheets | MDN
The ::-webkit-scrollbar CSS pseudo-element affects the style of an element's scrollbar when it has overflow:scroll; set.
Read more >
[Solved!] Scroll Bar Not Working in Excel (5 Easy Fixes)
1. Unfreeze Panes · 2. Unstuck SHIFT Key to Fix Scroll Bar Not Working · 3. Unmark 'Zoom on roll with IntelliMouse' to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found