当前位置: 首页 > wzjs >正文

门户网站设计装修网站怎么做的

门户网站设计,装修网站怎么做的,棋牌软件开发,wordpress网盘搜索引擎插件数据大屏表格数据,当表格内容超出(出现滚动条)时,无限循环滚动播放,鼠标移入暂停滚动,鼠标移除继续滚动;数据量小没有超出时不需要滚动。 *使用时应注意,滚动区域高度父元素高度 - 表…

数据大屏表格数据,当表格内容超出(出现滚动条)时,无限循环滚动播放,鼠标移入暂停滚动,鼠标移除继续滚动;数据量小没有超出时不需要滚动。
*使用时应注意,滚动区域高度=父元素高度 - 表头高度
1、组件内容

import React, { useState, useEffect, useRef } from "react";
import { Table } from "antd";
import { ColumnsType, TableRef } from "antd/lib/table";
import styles from "./styles.less";
import Nodate from "../Other/nodata";interface InfiniteScrollTableProps<T> {/** 表格数据源 */dataSource: T[];/** 表格列定义 */columns: ColumnsType<T>;/*** 唯一字段*/rowKeyField: string;/*** 滚动速率。* @default 0.5* @description 建议在 0.5-3 之间调整* */speed?: number;
}/*** @description 无限循环滚动table*/
const InfiniteScrollTable = <T = any,>(props: InfiniteScrollTableProps<T>) => {const { dataSource, columns, speed = 0.5, rowKeyField = "key" } = props;const [doubleData, setDoubleData] = useState<any[]>([]);const tableRef = useRef<TableRef>(null);const animationRef = useRef<number | null>(null);const isHovered = useRef(false);// 滚动高度const scrollHeight = useRef(0);// 滚动动画const startScrolling = (begin: boolean) => {if (isHovered.current || !tableRef.current || !tableHasScroll()) return;const table = tableRef.current.nativeElement;const wrapper = table.querySelector(".ant-table-body");if (!wrapper) {return;}// 重置滚动位置if (begin) {wrapper.scrollTop = 0;}const scroll = () => {if (isHovered.current) return;// 滚动到底部时重置位置if (wrapper.scrollTop >= wrapper.scrollHeight / 2) {wrapper.scrollTop = 0;} else {wrapper.scrollTop += speed;}animationRef.current = requestAnimationFrame(scroll);};animationRef.current = requestAnimationFrame(scroll);};// 表格内容是否出现滚动const tableHasScroll = () => {const table = tableRef.current?.nativeElement;const wrapper = table?.querySelector(".ant-table-body");if (!wrapper) {return false;}const hasScroll = wrapper.scrollHeight > wrapper.clientHeight;return hasScroll;};// 停止滚动const stopScrolling = () => {if (animationRef.current) {cancelAnimationFrame(animationRef.current);animationRef.current = null;}};// 处理鼠标事件const handleMouseEnter = () => {isHovered.current = true;stopScrolling();};const handleMouseLeave = () => {isHovered.current = false;startScrolling(false);};useEffect(() => {// 先设置为初始数据setDoubleData([...dataSource]);}, [dataSource]);// 开始滚动useEffect(() => {// 创建两倍数据用于实现无缝滚动if (tableHasScroll() && doubleData.length === dataSource.length) {setDoubleData([...dataSource, ...dataSource]);}startScrolling(true);return () => stopScrolling();}, [tableRef.current, doubleData]);return (<divref={(el) => (scrollHeight.current = el?.clientHeight || 0)}className={styles["infinite-scroll-table"]}onMouseEnter={handleMouseEnter}onMouseLeave={handleMouseLeave}><Tableref={tableRef}columns={columns}dataSource={doubleData}pagination={false}scroll={{ y: scrollHeight.current - 57 }}rowClassName={(record, index) =>index % 2 === 0 ? styles["even-row"] : styles["odd-row"]}rowKey={(record: any, index) => (record?.[rowKeyField] ?? "") + index}/></div>);
};export default InfiniteScrollTable;

2、样式

.infinite-scroll-table {position: relative;height: 100%;transition: all 0.3s ease;border: 1px solid rgba(187,187,187,1);.highlight {color: #40a9ff;font-weight: 600;}.even-row {background: rgba(255,255,255);height: 60px;}.odd-row {background: rgba(250,250,250);height: 60px;}:global {.ant-table-header{border-radius: 0;}.ant-table-thead > tr > th {background: rgba(242,242,242) !important;color: #333 !important;font-size: 14px;font-weight: 600;text-align: center;border-start-start-radius: 0 !important;border-start-end-radius: 0 !important;}.ant-table-body {scrollbar-width: none;-ms-overflow-style: none;}.ant-table-cell{font-weight: normal;font-size: 14px;}.ant-table-body::-webkit-scrollbar {display: none;}.ant-table-row:hover > td {background: rgba(64, 144, 255, 0.2) !important;}.ant-table-placeholder .ant-table-cell{border: none;}}}

文章转载自:

http://ZnfbjHZy.Lxngn.cn
http://WX4xEwqD.Lxngn.cn
http://i0sXNmpB.Lxngn.cn
http://80iM3iLu.Lxngn.cn
http://EEpn0D0u.Lxngn.cn
http://H5FKJPM4.Lxngn.cn
http://GDWgNeug.Lxngn.cn
http://l1tsn75m.Lxngn.cn
http://zCJLxQyd.Lxngn.cn
http://32F2PVuV.Lxngn.cn
http://7x9hZyqk.Lxngn.cn
http://Aw2gegeF.Lxngn.cn
http://nXwWGlRH.Lxngn.cn
http://iB5HsPju.Lxngn.cn
http://X0GsupWY.Lxngn.cn
http://DBfQWrMs.Lxngn.cn
http://V6lqzBuq.Lxngn.cn
http://9SFxrVLa.Lxngn.cn
http://tNIXYC49.Lxngn.cn
http://WEu2khlo.Lxngn.cn
http://SO73sM6L.Lxngn.cn
http://srArNwps.Lxngn.cn
http://vxYKmhvf.Lxngn.cn
http://BKkDFkC7.Lxngn.cn
http://WktIXh2m.Lxngn.cn
http://GleU9SCG.Lxngn.cn
http://BYh7CU1D.Lxngn.cn
http://gCJAyoF1.Lxngn.cn
http://uyOrqwiE.Lxngn.cn
http://VbRN6Tbt.Lxngn.cn
http://www.dtcms.com/wzjs/700299.html

相关文章:

  • 电子商务网站设计岗位主要是比较有名的diy制作网站
  • 做网站公司汉狮网络semiconductor
  • 做一个网站花2万贵吗wordpress 密码失败
  • 做购物比价的网站有哪些网站建设怎么样工作室
  • 上海做网站比较有名的公司有哪些下载牛霸软件
  • 响应式网站解决方案查询网站的外链
  • 常州城投建设工程招标有限公司网站wordpress安装一下
  • 仙居网站开发东莞市专注网站建设公司
  • 免费网站注册申请电子商务网站调研报告
  • 手机怎么建立自己网站太原百度快照优化排名
  • 顺义区专业网站制作网站建设重庆seo海洋qq
  • 宁波网站优化公司哪家好提升学历励志语录
  • 十大免费货源网站免费版权新开传奇网站999新服网
  • 宜兴网站设计网站改版要重新备案
  • 凡科网建站教程自己做婚恋网站
  • 大沥网站建设制作小语种网站建设 cover
  • 个人网站推广平台大全百度网盘app下载安装手机版
  • 天台县建设规划局网站笔记本做网站
  • 佛山大良营销网站建设asp 网站 内容静态化
  • wordpress网站如何加百度搜索塘厦网站仿做
  • 高校网站建设招标公告中国好设计
  • 南通优普网站建设团队长沙专业网站设计平台
  • 中国网站建设网页设计wordpress企业建站教程
  • wordpress分享视频网站wordpress插件破解下载地址
  • 廊坊做网站厂商定制泰州城乡建设网站
  • 西安网站建设优化服务公司什么平台可以发广告引流
  • 网站建设代码走查个人微信公众平台注册流程
  • 北京网站运营优化公司宁夏网站seo
  • 简洁大方网站建设网站建设职位要求
  • 临沂网站开发多少钱做网站买计划书