How to implement the Vue mouse wheel scrolling switching routing effect

How to implement the Vue mouse wheel scrolling switching routing effect

A root routing component (the root routing component under the app, which needs to be scrolled as its child component)
Add a mouse scroll time listener to the root route component, and call the listener in mounted. When jumping to other routes (jumping out of this root route), the root route component will be destroyed, so clear the event listener in the destroyed hook function of the root route.

Vue routing switching transition

Vue transition

<transition :name="transitionName">
      <div></div>
 </transition>

Use transition to wrap the component that needs to transition, or a div, or a route. When it is created or destroyed, the specified animation effect will be loaded. This animation effect needs to be specified by yourself. Here, the specified transitionName

Then declare this in data, but assign this value to ' ', because different names need to correspond to the forward or backward routing.

When the route is forward (downward in this case), specify slide-down

Then define the activation effects in different states of slide-down as transition effects

.slide-down-enter-active,
.slide-down-leave-active {
transition: all 500ms;
position: absolute;
}

Then define the start animation

.slide-down-enter {
opacity: 0;
transform: translate3d(0, 100%, 0);
}

Define the leave activation animation

.slide-down-leave-active {
opacity: 0;
transform: translate3d(0, -100%, 0);
}

The following is generally fixed, that is, declare -enter-active, -leave-active as a transition effect and then write -enter, -leave-active. The specific changes required are generally one -enter, one -leave-active.

Please add a description of the image

Next is how to determine whether the route is forward or backward. First, how to switch the route forward and backward

Next, how to determine whether it is the front or the back? When writing the route, write the meta, and when monitoring the route changes in the "root component", get the route information, and compare the sizes of the two to determine

Please add a description of the imagePlease add a description of the image

This is the end of this article about how to implement the Vue mouse wheel scrolling route switching effect. For more relevant Vue route switching content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Vue implements scrolling the mouse wheel to switch pages
  • Vue tab scrolls to a certain height, fixed at the top, click tab to switch different content operations
  • Vue implements full screen scrolling switching
  • Vue scroll tab follow switching effect
  • Solution to the bug that the page scroll position remains unchanged after vue2.0 route switching
  • The vue page switches to the scroll page to display the top instance
  • How to automatically scroll the scroll bar to the top when switching pages using vue-router in vue
  • Detailed explanation of scroll bar position and scroll listener events when using vue-router to switch pages
  • Vue sample code for implementing image scrolling (similar to the effect of a revolving lantern)
  • Vue implements 3D switching scrolling effect

<<:  Use of Linux watch command

>>:  Detailed explanation of mysql.user user table in Mysql

Recommend

Basic learning tutorial of table tag in HTML

Table label composition The table in HTML is comp...

HTML code text box limit input text box becomes gray limit text box input

Method 1: Set the readonly attribute to true. INPU...

Detailed steps to install mysql 8.0.18-winx64 on win10

1. First go to the official website to download t...

Detailed description of shallow copy and deep copy in js

Table of contents 1. js memory 2. Assignment 3. S...

Detailed explanation of MySQL slow log query

Slow log query function The main function of slow...

How to set up URL link in Nginx server

For websites with an architecture like LNMP, they...

Three Discussions on Iframe Adaptive Height Code

When building a B/S system interface, you often en...

Detailed description of the use of advanced configuration of Firewalld in Linux

IP masquerading and port forwarding Firewalld sup...

mysql5.7.19 winx64 decompressed version installation and configuration tutorial

Recorded the installation tutorial of mysql 5.7.1...

MySQL master-slave replication delay causes and solutions

Table of contents A brief overview of the replica...

MySQL intercepts the sql statement of the string function

1. left(name,4) intercepts the 4 characters on th...

Implementation of Docker building Maven+Tomcat basic image

Preface In Java programming, most applications ar...

foreman ubuntu16 quick installation

Quickstart Guide The Foreman installer is a colle...