当前位置:网站首页>JS how to realize the automatic scrolling and looping of the list
JS how to realize the automatic scrolling and looping of the list
2022-07-18 13:41:00 【Yisu cloud】
js How to realize the automatic scrolling and looping of the list
This article mainly introduces js How to realize the relevant knowledge of automatic scrolling and looping of the list , The content is detailed and easy to understand , The operation is simple and fast , It has certain reference value , I believe that after reading this article js How to realize the automatic scrolling and looping of the list and play the articles will be fruitful , Let's have a look .
1. Achieve the effect diagram
Mouse migration , Pause scrolling ; Mouse removal , Keep rolling

2. principle
To achieve seamless connection , In the original ul There should be a similar content later ul;
Outermost layer div Is the visible area , set up overflow:hidden;
2 individual ul Height > Outer visibility div Height , To scroll ;
3. Implementation code
html:
<!-- vue --><div id="review_box" @mouseover="rollStop()" @mouseout="rollStart(60)"> <ul id="comment1"> <li>1</li> <li>2</li> <li>3</li> <li>4</li> <li>5</li> </ul> <ul id="comment2"></ul></div>
css:
div { height: 100px; /* must */ overflow: hidden;/* must */}js:
//vue datadata (){ return { timer: null, }},mounted() { this.roll(60);},beforeDestroy() { if (this.timer) clearInterval(this.timer);},//vue methodsroll(t) { var ul1 = document.getElementById("comment1"); var ul2 = document.getElementById("comment2"); var ulbox = document.getElementById("review_box"); ul2.innerHTML = ul1.innerHTML; ulbox.scrollTop = 0; this.rollStart(t);},rollStart(t) { var ul1 = document.getElementById("comment1"); var ul2 = document.getElementById("comment2"); var ulbox = document.getElementById("review_box"); this.rollStop(); this.timer = setInterval(()=>{ // When the scroll height is greater than the height of the list content, it returns to 0 if (ulbox.scrollTop >= ul1.scrollHeight) { ulbox.scrollTop = 0; } else { ulbox.scrollTop++; } }, t);},rollStop(){ clearInterval(this.timer);},About “js How to realize the automatic scrolling and looping of the list ” That's all for this article , Thank you for reading ! I'm sure you're right “js How to realize the automatic scrolling and looping of the list ” Knowledge has a certain understanding , If you want to learn more , Welcome to the Yisu cloud industry information channel .
边栏推荐
- 双位置继电器DLS-5/1
- The second day of MATLAB learning (basic grammar, variables, commands and creating your own files)
- Zhongang Mining: Fluorite guarantees the supply of fluorine in new energy industry
- 类型的缩小
- 2.4_9 Mysql 按分隔符,行转列
- Qtcpserver multithreading implementation
- Sword finger offer 32 - I. print binary tree from top to bottom, breadth first search (queue)
- micro、M3O微服务系列(一)
- Dpdk flow filter summary (flow director/ rte_flow)
- MySQL 窗函数 流动平均数 running average
猜你喜欢

软件测试零基础测试篇-基本概念

Quick use of jdbctemplate

Halcon 3D create_ pose

Exploratory software testing

Research progress of transfer learning in medical image classification
![[software testing] test slang, the advice given to you by ten-year old employees](/img/69/b27255c303150430df467ff3b5cd08.gif)
[software testing] test slang, the advice given to you by ten-year old employees

Practice Guide for peanut shell inner net penetration

Working people working soul! Here comes the sales analysis case!

基于AMDP的BW转换专家例程

Zhongang Mining: Fluorite guarantees the supply of fluorine in new energy industry
随机推荐
More than 130 enterprises and 3500 developers have jointly built the root community of opengauss open source database
[TinyML]APQ:Joint Search for Network Architecture, Pruning and Quantization Policy
Guess the size of the number ii[what problem does dynamic planning solve?]
How does Xishanju build a game industry assembly line with ones? | Ones industry practice
The static variable looks a little dizzy, and the GDB assembly is awake
Recursively solve the traversal of binary trees (often test basic examples)
Time consuming evaluation of image pixel values accessed by opencv, emgucv and opencvsharp pointers (with source code)
使用pssh批量在多台主机上执行命令
High frequency interview questions -- subarray with sum K
Clickhouse (04) how to build a Clickhouse cluster
六、Jmeter定时器
[RT thread] NXP rt10xx device driver framework -- UART construction and use
The second day of MATLAB learning (basic grammar, variables, commands and creating your own files)
基本的unix域协议编程
u盘删除的文件怎么恢复
After Jay Chou's co branded model, Fang Wenshan brought online shopping to promote the collection of "Hualiu" top-level co branded dolls
7.15 Résumé du concours de simulation
Get started quickly, Jupiter notebook
探索式软件测试
Hcip first day study -- Review HCIA (static)