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

vue3 custom directive details

Table of contents 1. Registering custom instructi...

How to quickly import data into MySQL

Preface: In daily study and work, we often encoun...

A brief discussion on what situations in MySQL will cause index failure

Here are some tips from training institutions and...

Summary of WEBAPP development skills (notes for mobile website development)

1. To develop web responsively, the page must ada...

How to implement rounded corners with CSS3 using JS

I found an example when I was looking for a way t...

How to get the size of a Linux system directory using the du command

Anyone who has used the Linux system should know ...

VMware + Ubuntu18.04 Graphic Tutorial on Building Hadoop Cluster Environment

Table of contents Preface VMware clone virtual ma...

Using Docker to create static website applications (multiple ways)

There are many servers that can host static websi...

Use of MySQL SHOW STATUS statement

To do MySQL performance adjustment and service st...

MySQL partitioning practice through Navicat

MySQL partitioning is helpful for managing very l...

A complete guide to Linux environment variable configuration

Linux environment variable configuration When cus...

HTML table markup tutorial (37): background image attribute BACKGROUND

Set the background image for the table header. Yo...

Implementation ideas for docker registry image synchronization

Intro Previously, our docker images were stored i...