Vue is implemented with js partial control animation and vuejs partial Animation

Source: Internet
Author: User

Vue is implemented with js partial control animation and vuejs partial Animation

The last time we mentioned how to use vue to implement transition animation, We only talked about part of the vue animation. We used the css state control animation that comes with vue to implement it without js.

Http://www.cnblogs.com/null11/p/7081506.html

In vue, there is also a way to control the animation implementation, that is, using js to control the animation status

The three statuses are as follows:

: Before-enter = "name" before the animation enters : Enter = "name" after the animation enters : Leave = "name": the animation ends.

 

Next let's look at the instance

<! DOCTYPE html> 

In the html section, I used the animation function of jquery because of animation control. We will try our best to make things clean when using vue, so we should not use jquery when using vue.

The above uses the vue built-in animation component transition, and we are bound to the 3 medium state of the animation.

<Transition

V-on: before-enter = "beforeEnter"
V-on: enter = "enter"
V-on: leave = "leave"
V-bind: css = "false"

>

Or the previous graph, before entering, in progress, after entering

Next, we start to write the js part for control.

New Vue ({el: '# app', data: {show: true}, methods: {// before entering beforeEnter: function (el) {detail (el).css ({left: "-500px", opacity: 0})}, // enter: function (el, done) {$ (el ). stop (). animate ({left: 0, opacity: 1}, {duration: 1500, complete: done}, 5000)}, // end leave: function (el, done) {$ (el ). stop (). animate ({left: "500px", opacity: 0 },{ duration: 1500, complete: done}, 5000 )}}});

The three animation states are OK. Is it very simple?

 

 

 

 

 

 

 

 

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.