vue-page-swiper
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

vue-page-swiper

vue3 & vue router 4 page swiper with navigation direction specific transitions.

NPM Version

showcase

vue-page-swiper

usage

vue3 & vue router 4 are peer dependencies and must install along this lib.

// main.ts

import { createApp } from "vue"
import { createWebHashHistory } from "vue-router"

import { VuePageSwiper } from "vue-page-swiper"
import App from "./App.vue"
import { routes } from "./routes"

const app = createApp(App)

// app type: App<Element>
// options type: RouterOptions https://router.vuejs.org/api/interfaces/RouterOptions.html
VuePageSwiper(app, { routes, history: createWebHashHistory() }).mount("#app")
<!-- Vue page swiper container component-->
<template>
  <PageSwiper />
</template>
/* if you do not want horizontal scrollbar, apply following styles */

body,
html,
#app {
  height: 100%;
}

html,
body {
  margin: 0;
  padding: 0;
  border: 0;
  overflow-x: hidden;
}
// usePageSwiper usage 
import { usePageSwiper } from "vue-page-swiper"

// vue router 4 navigation methods
const { push, replace, back, forward } = usePageSwiper()

// navigation with direction specific transitions
// default transitions: 
// forward: swipe-right
// back: swipe-left
push("/page2")

// to type: https://router.vuejs.org/api/#RouteLocationRaw
// guide: https://router.vuejs.org/guide/essentials/navigation.html#Programmatic-Navigation
push({
  path: "/page2",
  // name: "page2",
  // query: { source: "dev" },
  // params: { username: "eduardo" }
  // hash: "#section5"
})

replace(
    "/page3",
    // optional once transition name
    "pageFade",
    // optional once transition mode
    "out-in"
    )

example

npm run dev

Dependencies (0)

    Dev Dependencies (18)

    Package Sidebar

    Install

    npm i vue-page-swiper

    Weekly Downloads

    0

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    11.7 kB

    Total Files

    12

    Last publish

    Collaborators

    • iou90