MSlider (.MSLIDER)

Simple fully functional Vue slider that supports touch screens.

Preview

Attributes

Nametypeoptionaldescription
carouselbooleantrueTo change slider to carousel mode (all other attributes depend on this one)
infinitebooleantrueTo make the infinite scrolling effect
stackedbooleantrueTo get the stacked cards looking slider
change-timebooleantrueTo make the slider change automatically in a certain time (in ms.)
pointersbooleantrueTo get slides pointers

Usage

Write the MSlider component and append any type of elements inside of it (better be of one aspect ratio). give it a ref and call next() and previous() to navigate. You can also navigate by swiping on touch screens or using pointers. You have to provide a transition for child elements to get the right sliding effect.

<template>
  <MSlider ref="slider" infinite stacked change-time="2000">
    <img src="nature.jpg" alt="3/1 picture" />
    <img src="space.jpg" alt="3/1 picture" />
    <img src="nature.jpg" alt="3/1 picture" />
    <img src="space.jpg" alt="3/1 picture" />
  </MSlider>
  <div>
    <MButton @click="$refs.slider.previous()"> Previous </MButton>
    <MButton @click="$refs.slider.next()"> Next </MButton>
  </div>
</template>
<style>
img {
  transition: all 0.2s ease;
}
</style>