Git Product home page Git Product logo

vue-page-transition's Introduction

vue-page-transition

npm npm vue2 Codacy Badge

A lean Vue.js plugin for page / route transitions.

Table of contents

Installation

yarn add vue-page-transition

or with npm

npm install vue-page-transition

Default import

Install the component:

import Vue from 'vue'
import VuePageTransition from 'vue-page-transition'

Vue.use(VuePageTransition)

Browser import

<script src="vue.js"></script>
<script src="vue-typed-js/dist/vue-page-transition.browser.js"></script>

The plugin should be auto-installed. If not, you can install it manually with the instructions below.

Install all the components:

Vue.use(VuePageTransition)

Usage

To get started simply wrap your router-view with the vue-page-transition component.

Minimal setup:

<vue-page-transition>
  <router-view/>
</vue-page-transition>

As a default the fade animation will be applied. If you want to use another animation you can do so by passing it via the name attribute:

<vue-page-transition name="fade-in-right">
  <router-view/>
</vue-page-transition>

You can find a list of all available transitions in the following section.

Notice: You can use the vue-page-transition component to wrap any element you would like to. The router-view is just the most commone use case.

Properties / Attributes

You can make use of the following properties in order to customize your typing expirience:

Property Type Description Example
name String The name of the desired transition. name="'fade-in-right'"

Overwrite transiton for single route

We've now covered how to set up a global transition by using the name attribute. But what if I want to use multiple transitions depending on the route? In this case you can simple add a transition property to the meta fields of your specific route.

Here's an example on how your router could look like:

export default new Router({
  routes: [
    {
      path: '/',
      name: 'HelloWorld',
      component: HelloWorld,
      // overwrite default transition
      meta: { transition: 'zoom' },
    },
  ]
})

Transitions

Here you can find a list of all the available transitions so far.

Fade

The default fade transtion smoothly changes the opacity between two elements / pages with the additional ability to add some direction.

Default Fade

The default fade transtion smoothly changes the visibility of the pages without any directional change.

Usage:

<vue-page-transition name="fade">...</vue-page-transition>

Up

The old page smoothly disappears, while the new page fades in from the bottom.

Usage:

<vue-page-transition name="fade-in-up">...</vue-page-transition>

Right

The old page smoothly disappears, while the new page fades in from right.

Usage:

<vue-page-transition name="fade-in-right">...</vue-page-transition>

Down

The old page smoothly disappears, while the new page fades in from top.

Usage:

<vue-page-transition name="fade-in-down">...</vue-page-transition>

Left

The old page smoothly disappears, while the new page fades in from left.

Usage:

<vue-page-transition name="fade-in-left">...</vue-page-transition>

Overlay

Overlay Up

The overlay grows from the bottom to the top and back.

Usage:

<vue-page-transition name="overlay-up">...</vue-page-transition>

Overlay Right

The overlay grows from the left to the right and back.

Usage:

<vue-page-transition name="overlay-right">...</vue-page-transition>

Overlay Down

The overlay grows from the top to the bottom and back.

Usage:

<vue-page-transition name="overlay-down">...</vue-page-transition>

Overlay Left

The overlay grows from the right to the left and back.

Usage:

<vue-page-transition name="overlay-left">...</vue-page-transition>

Overlay Down Full

The overlay grows from the top to the bottom and then shrinks from top to the bottom.

Usage:

<vue-page-transition name="overlay-down-full">...</vue-page-transition>

Overlay Right Full

The overlay grows from the left to the right and then shrinks from left to the right.

Usage:

<vue-page-transition name="overlay-right-full">...</vue-page-transition>

Overlay Up Full

The overlay grows from the bottom to the top and then shrinks from bottom to the top.

Usage:

<vue-page-transition name="overlay-up-full">...</vue-page-transition>

Overlay Left Full

The overlay grows from the left to the right and then shrinks from left to the right.

Usage:

<vue-page-transition name="overlay-left-full">...</vue-page-transition>

Overlay Up Down

The overlay grows from the bottom and top at the same time and back.

Usage:

<vue-page-transition name="overlay-up-down">...</vue-page-transition>

Overlay Left Right

The overlay grows from the left and right at the same time and back.

Usage:

<vue-page-transition name="overlay-left-right">...</vue-page-transition>

Flip

Flip X

The old page flips horizontally into the new page.

Usage:

<vue-page-transition name="flip-x">...</vue-page-transition>

Flip Y

The old page flips vertically into the new page.

Usage:

<vue-page-transition name="flip-y">...</vue-page-transition>

Zoom

Default Zoom

The old page smoothly zooms out and then new page zooms in.

Usage:

<vue-page-transition name="zoom">...</vue-page-transition>

Demo

Checkout the demo here.


License

MIT

vue-page-transition's People

Contributors

dependabot[bot] avatar orlandster avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vue-page-transition's Issues

Need to support Vue3

I'm working on a project with Vue3 (+Router 4 + Quasar 2) and tried to use this library and get the error

image

image

I guess it is because the library doesn't support Vue3.
If it's correct, please upgrade it.

Thanks a lot

Does not work in IE 11.

I have integrated this package in my simple project. For chrome, works well. but does not work in IE 11. I have got following error.
SCRIPT1003**: Excepted ':'** vue-page-transition.common.js (91, 1)
Please help me. Regards

Transitions on elements within vue-page-transition

It seems that I can't use the transition element on anything else within the vue-page-transition element, which I have around my router-view at the root of my app.

Is this something you are aware of or am I making a mistake?

[Fade-right]Think to hide overflow

Hi, in your demo (and in my project) i had an overflow effect with fade-right

To fix that,I just need to add
css:

#app {
  overflow-x: hidden;
}

html:

<div id="app">
   <vue-page-transition name="fade-in-right">
     <router-view class="auto-size" />
   </vue-page-transition>
 </div>

Thanks for your work

PostCSS import problem

Getting a PostCSS warning after adding this module (and using it): "You did not set any plugins, parser, or stringifier. Right now, PostCSS does nothing."

From reading about it, it seems the cause is the imports within the SCSS style block in the component that's being imported. Any chance you could provide an option to import a version of the component without scss in it?

EDIT: Thinking about it more it seems like a lame request. It's not your fault the interaction is faulty and your component is beautifully written. I'll try to work around it.

Create cleaner Demo

The demo should be much cleaner.

  • better demo content
  • intro page with links
  • etc.

Transition name is not applied if the route has never been changed.

First of all, I know that this plugin is meant to be used with the router-view, but a page doesn't necessarily mean a route to me. I have some special pages that I display with v-if on special cases, one of them is a login page. It is a page because covers the entire window page and hides everything else (because v-else). It appears first and only gets hidden on login.

If you want to dismiss this because it's not the intended use case, it's fine, I can still extend the component. Although, the issue and the fix are simple and shouldn't break stuff, maybe.

Now, for the issue; the name prop is not applied if the route has never been changed yet, because it only applies that on beforeEach route change. The plugin defaults to fade transition and will only apply the transition in name prop after a route change.

The fix is simple; set transition from name prop on created.

I'd also like to add that while 'fade' is the default value for transition, it is not the default value for the name prop. So, maybe you also want to set name prop default value to 'fade'.

The extending component I mentioned
<script>
import VuePageTransition from 'vue-page-transition/src/components/VuePageTransition';

const MyPageTransition = {
    name: "MyPageTransition",
    extends: VuePageTransition,
    created(){
        this.transition = this.$props.name;
    }
}
export { MyPageTransition }
export default MyPageTransition
</script>

randomizer of choices

would be nice with a randomizer function which baseicly randomizes the effect of predefined values.

<page-transition name="randomize" :names="["fade","flip"]>

opetions to change duration?

Maybe add _variables scss files that you can override? to change the defaults of the duration, maybe postcss? to solve it? but the feature would be nice.

TypeScript support

When I try to import vue-page-transition in TypeScript I'm getting this error : Could not find a declaration file for module 'vue-page-transition'. '/project/node_modules/vue-page-transition/dist/vue-page-transition.common.js' implicitly has an 'any' type

Multiple errors - " Property or method "loading" is not defined on the instance but referenced during render."

Every time a page is loaded I get this message:

[Vue warn]: Property or method "loading" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. See: https://vuejs.org/v2/guide/reactivity.html#Declaring-Reactive-Properties.

found in

---> <Vuex> at src/components/vuex.vue
       <VuePageTransition> at /Users/orlando/Desktop/contributions/vue-page-transitions/src/components/VuePageTransition.vue
         <VContent>
           <VApp>
             <App> at src/App.vue
               <Root>
warn @ webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:620
warnNonPresent @ webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:2014
get @ webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:2069
render
Vue._render @ webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:3536
updateComponent @ webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:4054
get @ webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:4467
run @ webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:4542
flushSchedulerQueue @ webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:4298
(anonymous) @ webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:1979
flushCallbacks @ webpack-internal:///./node_modules/vue/dist/vue.runtime.esm.js:1905

Not a big issue but it makes debugging difficult as I get 40 errors like this every time a page is loaded.

Overlay graphics?

How hard would it be to spruce up the overlays? Soild colors are a bit boring... Slap some images on the overlays or even a slot to put what ever you want! Now we are talking! Great plugin though! Just currently switch to it.

Transition name not changing the transition

I'm trying to use a transition other than the default fade. When passing a name it does not change anything.

// in main.js
import VuePageTransition from 'vue-page-transition'

Vue.use(VuePageTransition);

// in App.vue
<vue-page-transition name="overlay-left-full">

Change transition color on overlay

Hello and thank you for your work here.

Would like to know if I can change the color on the overlay transition - Blue is not in my color scheme.

Allow access to transition hooks

Perhaps use the following to allow users to hook into the transition lifecycle:

<transition v-bind="[$attrs, $props]" v-on="$listeners">

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.