Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

enso-carousel

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enso-carousel

A renderless Vue component carousel.

  • 2.0.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
4
decreased by-69.23%
Maintainers
1
Weekly downloads
 
Created
Source

A renderless Vue component carousel.

Limitations

  • The carousel and its slides must be 100vw wide.
  • Slides must not be <a> elements. If you want to use an <a> then put it inside the slide.

Installation

Use npm

npm install --save enso-carousel

or yarn

yarn add enso-carousel

Usage

MyCarousel.vue

<template>
  <enso-carousel
    @change="onChange"
    @ready="onReady"
    :slides="[
      {
        content: 'This is my carousel. Here is the first slide.',
      },
      {
        content: 'This is the second slide.',
      },
      {
        content: 'And here is the third slide.',
      },
    ]"
  >
    <div slot-scope="{ prev, next, goto, isCurrentIndex, slides }">
      <div class="enso-carousel__slides">
        <slide
          class="enso-carousel__slide"
          v-for="(slide, index) in slides"
          :key="'slide' + index"
          v-bind="slide"
        ></slide>
      </div>

      <button @click="prev">
        Previous
      </button>
      <button @click="next">
        Next
      </button>

      <ul>
        <li v-for="(slide, index) in slides" :key="index">
          <button @click="goto(index)" :class="{ 'is-active': isCurrentIndex(index) }">
            {{ index }}
          </button>
        </li>
      </ul>
    </div>
  </enso-carousel>
</template>

<script>
export default {
  methods: {
    onReady(slide) {
      console.log('The carousel is ready. This slide is showing.', slide);
    },
    onChange(slide) {
      console.log('A different slide was selected.', slide);
    },
  },
};
</script>

MySlide.vue

<template>
  <div>
    {{ content }}
  </div>
</template>

<script>
export default {
  props: {
    content: String,
  },
};
</script>
<template>
  <enso-carousel
    :slides="[
      {
        content: 'This is my carousel. Here is the first slide.',
        url: 'https://example.com',
      },
      {
        content: 'This is the second slide.',
        url: 'https://example.com',
      },
      {
        content: 'And here is the third slide.',
        url: 'https://example.com',
      },
    ]"
  >
    <div slot-scope="{ prev, next, goto, isCurrentIndex, slides }">
      <div class="enso-carousel__slides">
        <div
          v-for="(slide, index) in slides"
          :key="index"
        >
          <a
            :href="slide.url"
            class="enso-carousel__slide"
          >
            {{ slide.content }}
          </a>
        </div>
      </div>
    </div>
  </enso-carousel>
</template>

Props

  • slides - Array of slides
  • threshold - Number of pixels to drag before counting it as dragging to a new slide. Default 100.

Events

  • ready(slide)
  • change(slide)
  • drag-start
  • drag-move
  • drag-end

Methods

  • prev()
  • next()
  • goto(index)
  • isCurrentIndex(index)

Keywords

FAQs

Package last updated on 17 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc