An example of implementing a simple infinite loop scrolling animation in Vue

An example of implementing a simple infinite loop scrolling animation in Vue

This article mainly introduces an example of Vue implementing a simple infinite loop scrolling animation, which is shared with everyone. The details are as follows:

First look at the implementation effect:

This kind of carousel-like effect can usually be solved using a carousel solution, but compared to the solution I am going to share, the carousel implementation is still more complicated.
Vue provides a transition animation transition-group, which is the effect I use here.

// template
<transition-group name="list-complete" tag="div">
 <div
  v-for="v in items"
  :key="v.ix"
  class="item list-complete-item pro-panel"
  :style="{ height: sh }"
 >
  //Content part</div>
</transition-group>

//scss
.list-complete-item {
 transition: all 1s;
}
.list-complete-leave-to {
 opacity: 0;
 transform: translateY(-80px);
}
.list-complete-leave-active {
 position: absolute;
}

In this way, the animation effect comes out, but it cannot be executed automatically, so I use setInterval:

mounted() {
 let count = 4000
 if (!this.timer) {
  this.timer = setInterval(() => {
   if (this.items.length > 1) {
    this.remove()
    this.$nextTick().then(() => {
     this.add()
    })
   }
  }, count)
 }
},
methods: {
 add: function() {
  if (this.items && this.items.length) {
   const item = { ...this.removeitem[0] }
   item.ix = this.nextNum++
   this.items.push(item)
  }
 },
 remove: function() {
  this.removeitem = this.items.splice(0, 1)
 }
}

For example, it would be simpler to achieve the effect. By the way, the effect I achieved here is single-line scrolling, just like news scrolling, so the view window can only see one piece of data. You can also not limit it in this way, then the entire list can be displayed, but each time only a single piece of data will disappear.

PS: This method can be used for dynamic rendering of images

<img
 :src="require(`@/assets/imgs/icons/${somevar}.png`)"
>

Of course, if you have different opinions, please leave a message to communicate!

This concludes this article about an example of implementing a simple infinite loop scrolling animation with Vue. For more related Vue infinite scrolling animation content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • How to use v-for loop to generate dynamic tags in Vue.js
  • 7 Ways to Write a Vue v-for Loop
  • Attributes in vue v-for loop object
  • Implementing circular scrolling list function based on Vue
  • Detailed explanation of the loop form item example in Vue
  • This article will show you the event loop mechanism of vue.js

<<:  Implementing shopping cart function based on vuex

>>:  Vuex implements a simple shopping cart

Recommend

How to quickly paginate MySQL data volumes of tens of millions

Preface In backend development, in order to preve...

Bootstrap 3.0 study notes grid system principle

Through the brief introduction in the previous tw...

Detailed explanation of several examples of insert and batch statements in MySQL

Table of contents Preface 1.insert ignore into 2....

I have compiled a few cool design sites that I think are good.

You must have inspiration to design a website. Goo...

A brief introduction to MySQL functions

Table of contents 1. Mathematical functions 2. St...

Complete steps to build a squid proxy server in linux

Preface This article mainly introduces the releva...

CSS sample code to achieve circular gradient progress bar effect

Implementation ideas The outermost is a big circl...

How to make ApacheBench support multi-url

Since the standard ab only supports stress testin...

A brief discussion on HTML ordered lists, unordered lists and definition lists

Ordered List XML/HTML CodeCopy content to clipboa...

Vue achieves seamless carousel effect (marquee)

This article example shares the specific code of ...

Detailed analysis of javascript data proxy and events

Table of contents Data Brokers and Events Review ...

Implementation of installing and uninstalling CUDA and CUDNN in Ubuntu

Table of contents Preface Install the graphics dr...

js implements a simple English-Chinese dictionary

This article shares the specific code of js to im...