This article shares the specific code of the applet to realize the text loop scrolling through examples for your reference. The specific content is as follows Solving the problem: 1. Text loop playback effect 2. Exit the applet and stop the hidden background animation (solved) Effect: Code: wxml <view animation="{{animation}}" class="animation"> 919 test use - small program loop playback~~~ </view> wxss .animation{ width: 100%; transform: translateX(100%); position: fixed; top: 45%; font-size: 16px; font-weight: bold; } Final js /** * Life cycle function - listen for the completion of the initial rendering of the page*/ onReady: function () { this.bindAnimation(); }, bindAnimation(){ var this_ = this; var animation = wx.createAnimation({ duration: 5000, timingFunction: 'linear', transformOrigin:"100% 0 0" }) animation.translateX('-100%').step(); this.setData({ animation:animation.export(), }) //Set up loop animation this.animation = animation; setInterval(function(){ //The second animation text position initialization this.Animation2(); // Delay the scrolling animation (the effect will be better) setTimeout(function(){ this.animation.translateX('-100%').step(); this.setData({ animation: animation.export(), }) }.bind(this),200); }.bind(this),5000); }, /** * Initialize the second animation text position*/ Animation2(){ var this_ = this; var animation2 = wx.createAnimation({ duration: 0, timingFunction: 'linear', transformOrigin:"100% 0 0" }) animation2.translateX('100%').step(); this_.setData({ animation:animation2.export(), }) }, /** * Solve the problem of mini program exit and background animation stopping */ onHide: function () { //Solve the problem of mini program exit and background animation stopping //Re-trigger the animation method this.bindAnimation(); }, The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
>>: Tutorial on installing Docker in Windows 10 subsystem Ubuntu (WSL) (with pictures and text)
What is high concurrency? The default Linux kerne...
mysqldump command Introduction: A database backup...
Let me first introduce an interesting property - ...
Today I was dealing with the issue of migrating a...
First install ssh in Linux, taking centos as an e...
If you want to hide content from users of phones, ...
Adding indexes can improve query efficiency. Addi...
Copy code The code is as follows: <!DOCTYPE ht...
Suppose a user management system where each perso...
Install Remote-SSH and configure it First open yo...
To implement the "Enter != Submit" probl...
usemap is an attribute of the <img> tag, use...
Record the problems you solve for others. Problem...
The ".zip" format is used to compress f...
Table of contents Step 1: Log in as root user. St...