循环无缝滚动的列表知识点

  1. 动态渲染列表,高度动态计算
  2. 过渡动画
    1. css3 animation 动画
    2. style 动态修改 top动画

https://github.com/chenxuan0000/seamless-scroll/blob/master/src/content/seamless.js
https://github.com/chenxuan0000/vue-seamless-scroll/blob/master/src/components/myClass.vue
https://juejin.cn/post/6983595654652100616

https://www.jb51.net/article/178366.htm
https://www.jq22.com/demo/jqueryslide202004132315/

https://dev.to/dhilipkmr/creating-infinite-scroll-with-15-elements-4dg4
https://juejin.cn/post/7141304226470166565
Creating Infinite Scroll with 15 Elements

hooks 无缝轮动

https://blog.csdn.net/weixin_44952328/article/details/124150886

seamless-scroll

https://github.com/chenxuan0000/seamless-scroll
yarn add seamscroll
在线案例 https://chenxuan0000.github.io/seamless-scroll
seamless源码 https://github.com/chenxuan0000/seamless-scroll/blob/master/src/content/seamless.js

  1. import React, { useEffect, useRef, memo } from 'react';
  2. import { array } from 'prop-types';
  3. import * as seamless from 'seamscroll';
  4. import { isEqual } from 'lodash';
  5. import cls from 'classnames';
  6. import styles from './style.module.less';
  7. SeamlessList.propTypes = {
  8. dataSource: array.isRequired,
  9. };
  10. function SeamscrollList({ dataSource }) {
  11. const domRef = useRef(null);
  12. useEffect(() => {
  13. if (!domRef.current) return;
  14. seamless.init({
  15. dom: domRef.current,
  16. direction: 1, // 向上滚动 0 👇🏻; 1 👆🏻; 2 👈🏻; 3 👉🏻
  17. // step: 3, // 一次轮播多少个,默认一个
  18. singleHeight: 40, // 行高
  19. waitTime: 3000, // 单步滚动等待 3s
  20. });
  21. }, []);
  22. return (
  23. <section className={styles.container}>
  24. <ul ref={domRef}>
  25. {dataSource.map((it, index) => (
  26. <li className={styles.item}>
  27. <span className={styles.col}>序号</span>
  28. <a className={styles.col}>详情链接</a>
  29. <b className={styles.col}>字段</b>
  30. <time className={styles.col}>时间</time>
  31. </li>
  32. ))}
  33. </ul>
  34. </section>
  35. );
  36. }
  37. function propsEqual({ dataSource }, props) {
  38. return isEqual(dataSource, props.dataSource);
  39. }
  40. export default memo(SeamscrollList, propsEqual);

style.module.less

  1. .container {
  2. position: relative;
  3. height: 400px;
  4. overflow: hidden;
  5. .item {
  6. display: flex;
  7. height: 40px;
  8. line-height: 40px;
  9. cursor: pointer;
  10. &:nth-child(odd) {
  11. background-color: rgba(56, 66, 86, 0.6);
  12. }
  13. &:hover {
  14. background: rgba(250, 250, 250, 0.06);
  15. }
  16. }
  17. .col {
  18. flex: 1;
  19. padding-inline: 8px;
  20. }
  21. }

owl carousel轮播

依赖 jquery
https://owlcarousel2.github.io/OwlCarousel2/demos/demos.html