• Stars
    star
    131
  • Rank 275,038 (Top 6 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created about 3 years ago
  • Updated 4 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

A performance focused Vue carousel designed for SSR/SSG environments.

vue-ssr-carousel vue-ssr-carousel This project is using Percy.io for visual regression testing.

A performance focused Vue carousel designed for SSR/SSG environments. No JS is used to layout the carousel or it's slides. The goal is to improve LCP and CLS scores because there is no layout or markup changes when JS hydates. It's primarily designed for rendering "card" style slides (like for linking to articles or products) where the carousel-ness is conditionally applied based on the number of cards that are slotted in as well as the viewport width.

Check out the demo: https://vue-ssr-carousel.netlify.app.

Install

yarn add vue-ssr-carousel

Default

import SsrCarousel from 'vue-ssr-carousel'
import ssrCarouselCss from 'vue-ssr-carousel/index.css'
Vue.component 'ssr-carousel', SsrCarousel

Nuxt

// nuxt.config.js
export default {
  buildModules: [ 'vue-ssr-carousel/nuxt' ]
}

Usage

<ssr-carousel>
  <div class="slide">Slide 1</div>
  <div class="slide">Slide 2</div>
  <div class="slide">Slide 3</div>
</ssr-carousel>

For more examples, see the demo: https://vue-ssr-carousel.netlify.app.

Tips

  • If your slides are generated with v-for, use key values that are based on the data you are looping through. In other words, do v-for='slide in slides' :key='slide.id' rather that v-for='slide, index in slides' :key='index'.
  • Don't use v-if on the root element of slide components.

API

Props

Props Default Description
slides-per-page 1 How many slides are shown per page. Can be set to null to allow for flexible widths for slides. See https://vue-ssr-carousel.netlify.app/responsive and note the caveats mentiond within.
gutter 20 The size of the space between slides. This can a number or any CSS resolvable string. See https://vue-ssr-carousel.netlify.app/gutters.
paginate-by-slide false When false, dragging the carousel or interacting with the arrows will advance a full page of slides at a time. When true, the carousel will come to a rest at each slide.
pagination-label null Customizes the label used in aria labels to describe a page.
autoplay-delay 0 Add a delay in seconds for auto playing the slides. See https://vue-ssr-carousel.netlify.app/misc#autoplay.
loop false Boolean to enable looping / infinite scroll. See https://vue-ssr-carousel.netlify.app/looping.
center false Render the first slide in the middle of the carousel. Should only be used with odd numbers of slides-per-page. This results in the slides being rendered visually in a different order than the DOM which is an accessibility concern. See https://vue-ssr-carousel.netlify.app/looping.
peek 0 A width value for how far adjacent cards should peek into the carousel canvas. This can a number or any CSS resolvable string. See https://vue-ssr-carousel.netlify.app/peeking.
peek-left 0 Set peek value on just the left edge.
peek-right 0 Set peek value on just the right edge.
peek-gutter false Set peek value equal to gutter value.
feather false Fades out the left and right edges using a CSS mask-image gradient. Set to true to use the default 20px value or as number or any CSS resolvable string to set an explicit width. This is designed to be used with peek properties. See https://vue-ssr-carousel.netlify.app/peeking.
overflow-visible false Disables the overflow:hidden that wraps the slide track. You would do this if you want to handle that masking in an ancestor element. See https://vue-ssr-carousel.netlify.app/peeking.
no-drag false Disables the ability to drag the carousel.
show-arrows false Whether to show back/forward arrows. See https://vue-ssr-carousel.netlify.app/ui.
show-dots false Whether to show dot style pagination dots. See https://vue-ssr-carousel.netlify.app/ui.
rtl false Adjust layout for right to left sites. See https://vue-ssr-carousel.netlify.app/accessibility.
value undefined Used as part of v-model to set the initial slide to show. See https://vue-ssr-carousel.netlify.app/events.
responsive [] Adjust settings at breakpoints. See https://vue-ssr-carousel.netlify.app/responsive. Note, loop and paginate-by-slide cannot be set responsively.

Slots

Slots Description
default Where your slides get injected.
back-arrow Replace the default back icon. Slot props:
disabled - True if at first page when not looping.
next-arrow Replace the default next icon. Slot props:
disabled - True if at last page when not looping.
dot Replace the default pagination dots. Slot props:
index - The page index that the dot represents.
disabled - True if dot represents current page.

Methods

Methods Description
next() Go forward a page or slide, depending on the paginate-by-slide prop
back() Go back a page or slide, depending on the paginate-by-slide prop
goto(index) Go to an index. If paginate-by-slide is false, this equates to a page offset. If true, this equates to a slide offset.

Events

See https://vue-ssr-carousel.netlify.app/events

Events Description
change({ index }) Fired when the internal index counter changes.
input Same as change but intended for use with v-model.
press Fired on mouse or touch down.
release Fired on mouse or touch up.
drag:start Fired on start of dragging.
drag:end Fired on end of dragging.
tween:start({ index }) Fired when the carousel starts tweening to it's final position.
tween:end({ index }) Fired when the carousel has finished tweening to it's destination.

Why another carousel component

Issues with flickity

  • Not a Vue component, so extra work building a Vue wrapper for it.
  • No SSR support, delaying LCP scoring.
  • When JS hydrates, the slides get nested in a new parent, which affects LCP calculations.

Issues with vue-slick-carousel

  • Slick applies responsive rules only after JS inits. This also results in getting a Mismatching childNodes vs. VNodes error when the page hydrates at a viewport width that changes the slidesToShow.
  • It's extra work to make the carousel look the same before and after Slick inits, since you have to style them two different ways.
  • Difficulty determining if there's overflow after Slick inits because when Slick is initialized and infinite: true, Slick adds a full set of .slick-cloned slides before the "real" slides, and another full set after them
  • Doesn't handle being empty well.
  • When using custom arrows or dots, it would show a warning that the Nodes does not match.
  • Doesn't do a good job of preventing images and links within slides from preventing dragging.

More Repositories

1

croppa

Image thumbnail creation through specially formatted URLs for Laravel.
PHP
492
star
2

cloner

A trait for Laravel Eloquent models that lets you clone a model and it's relationships, including files. Even to another database.
PHP
458
star
3

decoy

A Laravel model-based CMS
PHP
303
star
4

tram

Cross-browser CSS3 transitions in JavaScript.
JavaScript
183
star
5

laravel-pug

Pug view adapter for Laravel and Lumen
PHP
159
star
6

vue-in-viewport-directive

Vue 2 directive that adds css classes when the element is the viewport
JavaScript
120
star
7

vue-in-viewport-mixin

Vue 2 mixin to determine when a DOM element is visible in the client window
JavaScript
102
star
8

vue-visual

Vue 2 image and video loader supporting lazy loading, background videos, fixed aspect ratios, low rez poster images, transitions, loaders, slotted content and more.
JavaScript
59
star
9

laravel-haml

Wraps MtHaml for ease use in Laravel
PHP
45
star
10

reporter

Generate styled logs of Laravel requests that include application timing, memory usage, input data, and sql queries
PHP
30
star
11

nuxt-stylus-resources-loader

Stylus resources (e.g. variables, mixins etc.) module for NuxtJs
JavaScript
25
star
12

upchuck

A simple, automatic handler of file uploads for Laravel's Eloquent models using using Flysystem.
PHP
22
star
13

body-scroll-toggle

Enables / disables scroll on the body
JavaScript
19
star
14

vue-height-tween-transition

Tween the height of the parent of transitioning items for use in accordions or carousels.
JavaScript
16
star
15

nuxt-spa-store-init

A simple Nuxt module that will hydrate the VueX store when running in SPA mode (not SSR)
JavaScript
15
star
16

scrapey

Get info about a URL such as you get when sharing a link on Facebook.
PHP
11
star
17

shopify-gtm-instrumentor

Helpers for sending standardized dataLayer events from a Shopify site, inspired by GA Enhanced Ecommerce.
JavaScript
11
star
18

freezer

Using Laravel, creates cached versions of full pages that can be served directly by Apache
PHP
9
star
19

nuxt-coffeescript-module

Adds Coffeescript support to your Nuxt app
JavaScript
8
star
20

vue-balance-text

A Vue directive that implements the "balance-text" package to create line breaks to make each line of text in an element equal.
JavaScript
8
star
21

vue-hamburger

A hamburger icon that transitions to a close icon
JavaScript
7
star
22

data-layer-events

Push clean events onto Google Tag Manager's dataLayer
JavaScript
7
star
23

php-library

PHP utility classes
PHP
7
star
24

stylus-library

Stylus utility mixins
Stylus
7
star
25

vue-tween-number

A Vue component that tweens a number value.
JavaScript
6
star
26

bukwild-contentful-utils

Utilities for interacting with Contentful, designed with Vue and Nuxt in mind.
JavaScript
5
star
27

lightkeeper

Averages multiple successive Lighthouse tests to arrive at a more accurate PageSpeed score
JavaScript
5
star
28

nuxt-page-transition-and-anchor-handler

Scroll to top before page transition, handle anchor links, and cross-dissolve between pages
JavaScript
4
star
29

sass-to-stylus

Script to convert a project's sass files to stylus
CoffeeScript
4
star
30

codebasehq

Tools for integrating Laravel apps with CodebaseHQ features
PHP
4
star
31

cloak

Opinionated Nuxt + Craft boilerplate
CoffeeScript
4
star
32

contentful-color-selector

A UI Extension for Contentful that generate a dropdown for selecting a space-wide color
HTML
4
star
33

vue-embed

Parse html from the CMS for use with statically generated sites
JavaScript
3
star
34

vue-in-view

Vue component for triggering animations, adding classes, firing events, and syncing slot variables based on visibility in the viewport.
JavaScript
3
star
35

sass-library

Sass utility mixins
CSS
3
star
36

create-cloak-app

Sets up a new Cloak (Nuxt + Craft/Contentful) based project.
CoffeeScript
3
star
37

vue-routing-anchor-parser

A Vue directive that parses child elements for internally linking anchor tags and binds their click events to use Vue Router's push().
JavaScript
3
star
38

buk-builder

NodeJS-based asset versioning, RequireJS build tool.
JavaScript
2
star
39

following-circles

Generative art demo using Backbone
JavaScript
2
star
40

katamari

Convert distances into terms that are more easily visualized
JavaScript
2
star
41

auto-publish

Automatically publish all Laravel workbench assets on every request
PHP
2
star
42

vscode-config

For collaborating on shared VS Code configuration.
2
star
43

asana-gitlab-bridge

Opinionated, self-hosted tool that keeps GitLab in sync with Asana
CoffeeScript
2
star
44

craft-webhook-scheduler

A Craft plugin that triggers webhooks when scheduled posts become active.
PHP
2
star
45

benchpress

Wordpress boilerplate
PHP
2
star
46

vue-unorphan

A Vue directive that implements the "unorphan" package to prevent line breaks between the last two words of an element.
JavaScript
2
star
47

craft-netlify-deploy-status

A Craft plugin that shows Netlify deploy statuses.
PHP
2
star
48

vue-detachable-header

Vue component that wraps your header and renders at the top of the viewport when scrolling up.
JavaScript
2
star
49

vue-modal

A component that renders a modal window with slotted content. Includes trapped tabbing for ADA compliance
JavaScript
1
star
50

cloak-i18n

Localization conventions for Cloak + Craft.
JavaScript
1
star
51

cloak-boilerplate

Modules that setup standard Cloak conventions.
JavaScript
1
star
52

js-library

JS utility modules
JavaScript
1
star
53

jquery-backbone-views

jQuery plugin for instantiating Backbone views from selected elements
JavaScript
1
star
54

nuxt-remote-asset-cache

Store remote assets in the local build during Nuxt generation
CoffeeScript
1
star
55

photoshop-actions

Photoshop actions we use
1
star
56

window-event-mediator

Mediator pattern for window event handling
JavaScript
1
star
57

filestack-test

Testing connecting to Filestack
PHP
1
star
58

cloak-sandbox

A simplified Cloak app for demos and experiments.
Stylus
1
star
59

vue-cover-video-component

Vue component for dynamically loading single-page HTML 5 videos
Vue
1
star
60

light-or-dark

Return whether a hex or rgb color is light or dark
JavaScript
1
star
61

react-visual

Renders images and videos into a container.
TypeScript
1
star
62

sitemap-from-routes

Generate a sitemap directly from your Laravel routes/web.php.
PHP
1
star
63

cloak-algolia

Nuxt module for syncing records to Algolia and bootstrapping Instantsearch.js
JavaScript
1
star
64

vue-media-loader-directive

Vue Directive preloads media depending on pixel density and viewport size
CoffeeScript
1
star