Skip to content

⚡️ Lightweight Carousel based on CSS Scroll Snapping (Vue 2/3)

License

Notifications You must be signed in to change notification settings

abstractedillusion/vue-snap

 
 

Repository files navigation

vue-snap

Lightweight Carousel based on CSS Scroll Snap.

vue-snap logo

npm version Build Status npm bundle size license

Buy Me a Coffee

Table of Contents

About

Idea behind this plugin is that to create fully responsive and well optimised Carousel. We used new CSS properties Scroll Snapping, which allows us to lock the Carousel Wrapper to certain Slides or locations after a user has finished scrolling. This helps us to minimize library size, with only critical part, and avoid any heavy JS calculations or any CSS Hacks inside.

Examples/Stories

Pros:

  • Lightweight (5-10x times lighter than other libs)
  • There is no calculation or heavy logic inside (Performence aspect)
  • Fully responsive and mostly all customization via CSS - like how many Slides do you want to display
  • ESM Bundle with Dead Code Elimination (Tree Shaking)
  • SSR Support like Nuxt.js 🎉 (More here)
  • Vue@3 and Vue@2 Support 🎉 (More here)
  • Support all modern/common browsers (More here)

Installation & Usage

Vue@3 version

Installation

  yarn add vue-snap@next // or npm install vue-snap@next

Usage - Globally

import { createApp } from 'vue'
import App from './App.vue'

import VueSnap from 'vue-snap'
import 'vue-snap/dist/vue-snap.css'

const myApp = createApp(App)

myApp.use(VueSnap)
myApp.mount('#app')

Usage - Locally

import { Carousel, Slide } from 'vue-snap'
import 'vue-snap/dist/vue-snap.css'

export default {
  components: {
    Carousel,
    Slide
  }
}

Vue@2 version

Installation

  yarn add vue-snap // or npm install vue-snap

Usage - Globally

import Vue from 'vue'
import VueSnap from 'vue-snap'
import 'vue-snap/dist/vue-snap.css'

Vue.use(VueSnap)

Usage - Locally

import { Carousel, Slide } from 'vue-snap'
import 'vue-snap/dist/vue-snap.css'

export default {
  components: {
    Carousel,
    Slide
  }
}

Examples usage

Check out examples folder for more details.

Development

Install necessary depandancies

  yarn // or npm install

Run Storybook for development mode

  yarn storybook:dev

Release

  yarn release

Contribution

If you have a feature request then feel free to start a new issue, or just grab existing one.

License

MIT

About

⚡️ Lightweight Carousel based on CSS Scroll Snapping (Vue 2/3)

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 58.9%
  • Vue 35.3%
  • SCSS 5.8%