npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@morev/vue-swiper

v2.0.0

Published

Latest Swiper with extra features. For Vue 2 + SSR

Downloads

73

Readme

@morev/vue-swiper (still WIP)

Stability of "master" branch License: MIT Last commit Release version GitHub Release Date Keywords

Wrapper under latest Swiper (8.4.2) with extra features working with Vue 2.
SSR / Nuxt friendly.

Most of part API is compatible with original Swiper Vue component, so see the provided link for base docs.

Changes from original Swiper Vue component

  • If your environment (such as Nuxt 2 in context of webpack) doesn't support resolution of exports field in package.json, you need to import stylesheets by direct path.
    Original Swiper module places files in package root, this package re-exports it in dist folder. So:

    // Original package direct imports
    import '~swiper/swiper.min.css'
    import '~swiper/modules/pagination/pagination.min.css'
    
    // This package handles it another way
    import '~@morev/vue-swiper/dist/swiper.min.css'
    import '~@morev/vue-swiper/dist/modules/pagination/pagination.min.css'

    If your environment can resolve exports field in package.json there is no changes, just change the package name from swiper to @morev/vue-swiper.

  • There is no typings (WIP)

Extra features

Unfortunately, I currently have no time to do proper documentation, playground and even tests, so here is just short info about extra features:

  • prop lazyInit - boolean
    Allows to initialize Swiper only when it becomes visible (utilizing IntersectionObserver under the hood)

  • prop disabled - boolean
    Allows to render the default <slot></slot> content without swiper layout.
    Just an wrapper called swiper-root and slot content inside.
    This is suitable, for example, for blocks that have a grid layout on the desktop and turn into a slider on mobile devices.

    In this case you don't need to wrap each element in <swiper-slide> component - plugin will do it for you.

  • prop emitStyle - string (camelCase (default) or kebab-case)
    Allows to customize emits style. By default Swiper utilizes @camelCasedEvents, but if you prefer (like me) @kebab-cased-events you can set this prop to kebab-case. Just a stylistic thing.

    In Vue 3 there is no difference between @onEvent and @on-event, but Vue 2 handles them different.

  • prop bemBlock - string
    If you prefer (like me) to use BEM methodology, plugin can set BEM classes to Swiper elements alongside the Swiper classes (.swiper, .swiper-wrapper, etc).
    So, if bem-block="foo" is passed, then you can access swiper elements like .foo__swiper-wrapper, .foo__swiper-slide, etc.

  • prop navigationWrap - boolean
    Allows to wrap automatically created elements .swiper-button-prev and .swiper-button-next to common container .swiper-navigation.
    That's can be useful for custom styling.

  • prop navigationOutside - boolean
    Allows to render automatically created Navigation outside of .swiper element (which has overflow: hidden by design).

  • prop paginationWrap - boolean
    Wraps automatically created .swiper-pagination to extra wrapper .swiper-pagination-wrapper.
    That's can be useful for custom styling.

  • prop paginationOutside
    Allows to render automatically created Pagination outside of .swiper element (which has overflow: hidden by design).

  • prop scrollbarWrap - boolean
    Wraps automatically created .swiper-scrollbar to extra wrapper .swiper-scrollbar-wrapper.
    That's can be useful for custom styling.

  • prop scrollbarOutside
    Allows to render automatically created Scrollbar outside of .swiper element (which has overflow: hidden by design).

  • props rootTag and rootClass
    Because of navigationOutside, paginationOutside and scrollbarOutside all swiper markup should be wrapped with extra node.
    Those props allows to customize tagName and className of this element.

  • Slides have the not-initialized class before swiper is initialized.
    It allows to style them properly before initialization (during SSR / hydration) to minimize CLS.

Installation

Note: You don't need to install Swiper alongside this package - it has Swiper as dependency and re-exports all things you need such as modules / stylesheets.

Using yarn

yarn add @morev/vue-swiper

Using npm

npm install @morev/vue-swiper

Using pnpm

pnpm add @morev/vue-swiper

Usage

<template>
  <swiper
    :slidesPerView="3"
    :spaceBetween="20"
    :navigation="true"
    :modules="modules"
  >
    <swiper-slide>Slide 1</swiper-slide>
    <swiper-slide>Slide 2</swiper-slide>
    <swiper-slide>Slide 3</swiper-slide>
    <!-- ... -->
  </swiper>
</template>

<script>
  import { Swiper, SwiperSlide, Navigation } from '@morev/vue-swiper';
  import '@morev/vue-swiper/dist/swiper-bundle.min.css';

  export default {
    components: {
      Swiper,
      SwiperSlide,
    },
    data: () => ({
      modules: [Navigation],
    }),
  };
</script>