Nuxt Nationカンファレンス開催!11月12日~13日

swiper
nuxt-swiper

Swiper.jsのためのNuxtモジュール - ハードウェアアクセラレーションによるトランジションを備えた、最新のモバイルタッチスライダーです。
Cover Image

nuxt-swiper

Nuxt 3向けSwiper.js

Version Downloads MIT

Nuxt 3向けのフル機能搭載Swiper.jsモジュールです。使用方法の詳細については、Swiper.jsをご覧ください。

機能

  • 🚀 Nuxt 3サポート
  • 📖 オープンソース
  • 🪄 TypeScriptサポート
  • ✨ 自動インポート有効
  • ✨ 魔法のようにすぐに動作します ✨

StackBlitzデモ

お試しになりたいですか?以下のデモをご覧ください。

Open in StackBlitz

インストール

# npm
npm install nuxt-swiper

# yarn
yarn add nuxt-swiper

#pnpm
pnpm add nuxt-swiper

セットアップ

// nuxt.config.ts
import { defineNuxtModule } from 'nuxt'

export default defineNuxtConfig({
  modules: ['nuxt-swiper']
  swiper: {
    // Swiper options
    //----------------------
    // prefix: 'Swiper',
    // styleLang: 'css',
    // modules: ['navigation', 'pagination'], // all modules are imported by default
  }
})

使用方法

コンポーネント名自動インポート
<Swiper />
<SwiperSlide />

デフォルトプレフィックス:Swiper

モジュールオプションでプレフィックスを変更できます。

モジュール名自動インポート
SwiperA11y
SwiperAutoplay
SwiperController
SwiperEffectCreative
SwiperEffectCoverflow
SwiperEffectCube
SwiperEffectFade
SwiperEffectFlip
SwiperFreeMode
SwiperGrid
SwiperHashNavigation
SwiperHistory
SwiperKeyboard
SwiperLazy❌ - 削除済み Swiper ^9.0.0
SwiperMousewheel
SwiperManipulation
SwiperNavigation
SwiperPagination
SwiperParallax
SwiperScrollbar
SwiperThumbs
SwiperVirtual
SwiperZoom
<template>
  <Swiper
    :modules="[SwiperAutoplay, SwiperEffectCreative]"
    :slides-per-view="1"
    :loop="true"
    :effect="'creative'"
    :autoplay="{
      delay: 8000,
      disableOnInteraction: true,
    }"
    :creative-effect="{
      prev: {
        shadow: false,
        translate: ['-20%', 0, -1],
      },
      next: {
        translate: ['100%', 0, 0],
      },
    }"
  >
    <SwiperSlide v-for="slide in 10" :key="slide">
      <strong>{{ slide }}</strong>
    </SwiperSlide>
  </Swiper>
</template>

モジュールオプション

type SwiperStyleLangType = 'css' | 'scss'
type SwiperModulesType =
  | 'a11y'
  | 'autoplay'
  | 'controller'
  | 'free-mode'
  | 'grid'
  | 'hash-navigation'
  | 'history'
  | 'keyboard'
  | 'manipulation'
  | 'mousewheel'
  | 'navigation'
  | 'pagination'
  | 'parallax'
  | 'scrollbar'
  | 'thumbs'
  | 'virtual'
  | 'zoom'
  | `effect-${SwiperInterface['effect']}`

export interface SwiperModuleOptions {
  /**
   * The prefix to use for the Swiper Modules to import.
   * This is useful for importing only the modules you need and
   * avoiding importing the entire Swiper library.
   *
   * e.g. `${prefix}Autoplay` -> `SwiperAutoplay`
   *
   * @default 'Swiper' - import components from 'swiper/vue' by default
   */
  prefix?: string

  /**
   * Which type of lang of styles to import
   *
   * @default 'css' - imports css from 'swiper/css' by default
   */
  styleLang?: SwiperStyleLangType

  /**
   * Swiper modules to import
   *
   * '*' - imports all modules
   * '['thumbs', 'lazy']' - imports only specified modules
   *
   * @default '*' - imports all modules by default
   */
  modules?: '*' | SwiperModulesType[]
}

export {}

💻 開発

  • このリポジトリをクローンします
  • Corepackcorepack enableを使用して有効にします
  • pnpm install --shamefully-hoistを使用して依存関係をインストールします
  • pnpm devでプレイグラウンドを開きます

➕ コントリビューション

コントリビューションは、オープンソースコミュニティを素晴らしい学習、インスピレーション、創造の場にするものです。皆様からの貢献は **大歓迎** です。

  1. プロジェクトをフォークします
  2. 機能ブランチを作成します (git checkout -b feature/AmazingFeature)
  3. 変更をコミットします (git commit -m 'Add some AmazingFeature')
  4. ブランチをプッシュします (git push origin feature/AmazingFeature)
  5. プルリクエストを開きます

クレジット

swiper@nolimits4web によって開発されました。nuxt-swiper@cpreston321 によって開発されました。

📜 ライセンス

MIT ライセンス © 2022 cpreston321

📧 お問い合わせ

cpreston321 - @cpreston321

また、私の仕事がお気に召したら、コーヒーをご馳走して頂けると嬉しいです ☕️

Logo

🔥 コントリビューター