Convert Figma logo to code with AI

jaweii logoVueg----page-transition-plugin

为Vue应用添加页面间的转场特效( Page level transition plugin for vue-router)

1,046
143
1,046
10

Top Related Projects

🚦 The official router for Vue 2

208,167

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

55,800

The Intuitive Vue Framework.

22,645

📝 Minimalistic Vue-powered static site generator

29,761

🛠️ webpack-based tooling for Vue.js Development

🎉 A curated list of awesome things related to Vue.js

Quick Overview

Vueg is a Vue.js plugin that provides smooth page transition effects for Single Page Applications (SPAs). It enhances the user experience by adding animated transitions between route changes, making navigation feel more fluid and engaging.

Pros

  • Easy to integrate with existing Vue.js projects
  • Customizable transition effects and durations
  • Supports both Vue 2 and Vue 3
  • Lightweight and performant

Cons

  • Limited documentation and examples
  • May not work well with complex page layouts
  • Potential conflicts with other Vue plugins or custom transition implementations
  • Requires careful consideration of performance impact on larger applications

Code Examples

  1. Basic installation and usage:
import Vue from 'vue'
import App from './App.vue'
import router from './router'
import vueg from 'vueg'
import 'vueg/css/transition.css'

Vue.use(vueg, router)

new Vue({
  router,
  render: h => h(App)
}).$mount('#app')
  1. Customizing transition options:
Vue.use(vueg, router, {
  duration: '0.6', // transition duration
  enter: 'fadeInRight', // enter transition
  leave: 'fadeOutLeft', // leave transition
  shadow: false, // disable shadow effect
  disable: false, // disable transitions globally
  map: { // custom transition map
    '/': 'fade',
    '/about': 'slideLeft'
  }
})
  1. Disabling transitions for specific routes:
{
  path: '/no-transition',
  component: NoTransitionComponent,
  meta: {
    vueg: false // disable transition for this route
  }
}

Getting Started

  1. Install the plugin:

    npm install vueg
    
  2. Import and use the plugin in your main.js file:

    import Vue from 'vue'
    import App from './App.vue'
    import router from './router'
    import vueg from 'vueg'
    import 'vueg/css/transition.css'
    
    Vue.use(vueg, router)
    
    new Vue({
      router,
      render: h => h(App)
    }).$mount('#app')
    
  3. Add the v-transition attribute to your router-view component:

    <router-view v-transition></router-view>
    
  4. Customize transitions as needed using the options object when initializing the plugin.

Competitor Comparisons

🚦 The official router for Vue 2

Pros of vue-router

  • Official Vue.js routing solution, ensuring compatibility and long-term support
  • Extensive documentation and large community support
  • Advanced features like nested routes, dynamic route matching, and navigation guards

Cons of vue-router

  • Lacks built-in page transition animations
  • Requires more setup and configuration for complex routing scenarios
  • May have a steeper learning curve for beginners

Code Comparison

vue-router:

import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const router = new VueRouter({
  routes: [
    { path: '/foo', component: Foo },
    { path: '/bar', component: Bar }
  ]
})

Vueg----page-transition-plugin:

import Vue from 'vue'
import vueg from 'vueg'
import 'vueg/css/transition.css'

Vue.use(vueg, router)

// In component template
<transition name="fade" mode="out-in">
  <router-view></router-view>
</transition>

Summary

vue-router is the official routing solution for Vue.js, offering robust features and extensive community support. It excels in handling complex routing scenarios but requires more setup for animations. Vueg----page-transition-plugin focuses on providing smooth page transitions with minimal configuration, making it easier to implement animations but lacking some of the advanced routing features of vue-router. The choice between the two depends on the project's specific requirements for routing complexity and desired transition effects.

208,167

This is the repo for Vue 2. For Vue 3, go to https://github.com/vuejs/core

Pros of Vue

  • Comprehensive framework for building full-scale web applications
  • Large ecosystem with extensive documentation and community support
  • Flexible and scalable for projects of various sizes

Cons of Vue

  • Steeper learning curve for beginners compared to Vueg
  • Potentially overkill for simple projects or single-page transitions
  • Requires more setup and configuration for basic functionality

Code Comparison

Vue (basic component):

<template>
  <div>{{ message }}</div>
</template>

<script>
export default {
  data() {
    return {
      message: 'Hello Vue!'
    }
  }
}
</script>

Vueg (page transition):

import Vue from 'vue'
import App from './App'
import router from './router'
import vueg from 'vueg'
import 'vueg/css/transition.css'

Vue.use(vueg, router)

new Vue({
  el: '#app',
  router,
  render: h => h(App)
})

Summary

Vue is a full-featured framework suitable for complex applications, while Vueg focuses specifically on page transitions. Vue offers more flexibility and scalability but requires more setup. Vueg provides a simpler solution for adding smooth transitions between pages in Vue applications. The choice between them depends on the project's scope and requirements.

55,800

The Intuitive Vue Framework.

Pros of Nuxt

  • Full-featured framework for building Vue.js applications with server-side rendering, static site generation, and more
  • Extensive ecosystem with a wide range of modules and plugins
  • Built-in routing, state management, and development tools

Cons of Nuxt

  • Steeper learning curve due to its comprehensive nature
  • Potentially heavier bundle size for smaller projects
  • May introduce unnecessary complexity for simple single-page applications

Code Comparison

Vueg (page transition plugin):

import Vue from 'vue'
import App from './App'
import router from './router'
import vueg from 'vueg'
Vue.use(vueg, router)

Nuxt:

// nuxt.config.js
export default {
  modules: ['@nuxtjs/axios'],
  plugins: ['~/plugins/my-plugin.js'],
  css: ['~/assets/css/main.css']
}

Summary

Vueg is a lightweight page transition plugin for Vue.js, focusing specifically on enhancing page transitions. Nuxt, on the other hand, is a comprehensive framework built on top of Vue.js, offering a wide range of features including server-side rendering, static site generation, and more. While Vueg is easier to integrate into existing Vue projects for quick transition enhancements, Nuxt provides a more robust foundation for building complex applications with additional built-in functionality and an extensive ecosystem.

22,645

📝 Minimalistic Vue-powered static site generator

Pros of VuePress

  • Designed specifically for creating documentation sites, with built-in features for technical writing
  • Offers a default theme optimized for documentation, reducing setup time
  • Integrates seamlessly with Vue.js ecosystem and components

Cons of VuePress

  • Less flexible for general-purpose page transitions compared to Vueg
  • Requires more setup and configuration for non-documentation projects
  • May have a steeper learning curve for developers unfamiliar with Vue.js

Code Comparison

Vueg (page transition):

import Vue from 'vue'
import App from './App'
import router from './router'
import vueg from 'vueg'
Vue.use(vueg, router)

VuePress (basic config):

module.exports = {
  title: 'Hello VuePress',
  description: 'Just playing around',
  themeConfig: {
    nav: [
      { text: 'Home', link: '/' },
      { text: 'Guide', link: '/guide/' },
    ]
  }
}

Summary

Vueg is a lightweight plugin focused on page transitions for Vue.js applications, offering easy implementation of smooth transitions between routes. VuePress, on the other hand, is a full-fledged static site generator tailored for creating documentation websites. While Vueg provides more flexibility for custom page transitions, VuePress offers a comprehensive solution for documentation projects with built-in features and optimizations. The choice between the two depends on the specific needs of your project: custom page transitions (Vueg) or a documentation-focused site (VuePress).

29,761

🛠️ webpack-based tooling for Vue.js Development

Pros of vue-cli

  • Comprehensive tooling for Vue.js development, including project scaffolding, build setup, and plugin management
  • Official Vue.js tool with extensive documentation and community support
  • Provides a full-featured development environment with hot-reloading, linting, and testing capabilities

Cons of vue-cli

  • Larger learning curve for beginners due to its extensive features and configuration options
  • May be overkill for small projects or simple page transitions
  • Requires more setup time compared to lightweight plugins focused on specific functionalities

Code Comparison

vue-cli (project creation):

vue create my-project
cd my-project
npm run serve

Vueg (usage in a Vue component):

import vueg from 'vueg'
Vue.use(vueg, router)

// In component template
<transition name="fade" mode="out-in">
  <router-view></router-view>
</transition>

While vue-cli provides a complete development environment for Vue.js projects, Vueg focuses specifically on page transitions. vue-cli offers more extensive features and customization options, making it suitable for larger projects. Vueg, on the other hand, is a lightweight plugin that can be easily integrated into existing Vue.js applications to add smooth page transitions with minimal setup.

🎉 A curated list of awesome things related to Vue.js

Pros of awesome-vue

  • Comprehensive resource collection for Vue.js ecosystem
  • Regularly updated with community contributions
  • Covers a wide range of Vue-related topics and tools

Cons of awesome-vue

  • Not a functional plugin or component
  • Requires manual exploration to find specific resources

Code comparison

While a direct code comparison isn't relevant due to the nature of these repositories, here's a brief example of how they might be used:

awesome-vue:

## UI Components
- [Vue-multiselect](https://github.com/shentao/vue-multiselect) - Universal select/multiselect/tagging component for Vue.js.
- [vue-table-component](https://github.com/spatie/vue-table-component) - A straightforward Vue component to make force-filling tables a cinch.

Vueg:

import Vue from 'vue'
import App from './App'
import router from './router'
import vueg from 'vueg'
import 'vueg/css/transition-min.css'

Vue.use(vueg, router)

Summary

awesome-vue serves as a curated list of Vue.js resources, while Vueg is a specific page transition plugin. awesome-vue is more comprehensive but requires manual exploration, whereas Vueg provides immediate functionality for page transitions in Vue applications.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README


Example:

使用方法

安装插件

npm i vueg --save

引入插件

import vueg from 'vueg'

Vue.use(vueg, new Router(), Options) // 传入实例化后的router, Options为可选的插件配置

插件指令

插件注册了名为v-transition的指令,接收一个可选的Options参数,其包含的配置优先级高于全局配置。

启用插件:

为router-view添加v-transition指令后,该router-view下所有的页面都将启用动画:

<router-view v-transition></router-view>

或,为template中的顶级标签添加v-transition指令后,该页面组件将启用动画效果:

<template>
    <page v-transition>
    </page>
</template>

支持Nuxt。


Options

@property {number} duration 动画时长。默认为0.3
@property {string} enter 入场动画,默认为'fadeInRight'
@property {string} leave 离场动画,默认为'fadeInLeft'
@property {boolean} disableAtSameDepths 深度相同时禁用动画(通过url中的反斜杠数量/判断)。默认为false
@property {boolean} shadow 是否为入场页面添加阴影。默认为true
@property {Object} map 默认为空情况下,vueg根据url深度判断是入场还是离场,但有时可能并不是你想要的效果,这时你可以使用map选项。
例子:`
map: {
 'user-login':{
    enter: ['user-register'],
    leave: ['index'],
    disable: ['user-login-sms']
  }
 }
 `
上面例子表示,从名为`user-login`的路由到名为`user-regiseter`的路由转场,使用入场动画,反之则使用离场动画。
从名为`user-login`的路由到名为`index`的路由转场,使用离场动画,反之则使用入场动画。
从名为`user-login`的路由到名为`user-login-sms`的路由转场,禁用转场动画。



enter、leave 参数使用的animate.css的动画类名作为值,查看全部可用值,请访问:https://daneden.github.io/animate.css。 另外插件自带了一个可用值 touchPoint,动画效果为页面从触摸(点击)点放大入场。

NPM DownloadsLast 30 Days