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

WeChat applet implements the snake game

This article shares the specific code of the WeCh...

Basic knowledge points of mysql worm replication

Worms replicate, as the name implies, by themselv...

Introduction to SSL certificate installation and deployment steps under Nginx

Table of contents Problem description: Installati...

Detailed explanation of Vue router routing

Table of contents 1. Basic use 2. Several points ...

Detailed explanation of redo log and undo log in MySQL

The most important logs in the MySQL log system a...

Click the toggle button in Vue to enable the button and then disable it

The implementation method is divided into three s...

In-depth explanation of MySQL isolation level and locking mechanism

Table of contents Brief description: 1. Four char...

JavaScript function call classic example code

Table of contents JavaScript function call classi...

Example of how to adapt the Vue project to the large screen

A brief analysis of rem First of all, rem is a CS...

In-depth analysis of the slow query problem of MySQL Sending data

Through an example, I shared with you the solutio...

Differences between FLOW CHART and UI FLOW

Many concepts in UI design may seem similar in wo...