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

网站的角色设置如何做北京建站免费模板

网站的角色设置如何做,北京建站免费模板,乐陵森林面积,天元建设集团有限公司承兑汇票兑付vue3elementPluscssjs 模拟liMarquee插件,实现无限滚动效果 功能:1、表格数据大于一定数量之后,开始向上滚动 2、当鼠标移入的时候,动画停止,鼠标移出,继续动画 3、滚动动画的速度可以自定义 4、表格的高度…

vue3+elementPlus+css+js 模拟liMarquee插件,实现无限滚动效果

功能:1、表格数据大于一定数量之后,开始向上滚动

           2、当鼠标移入的时候,动画停止,鼠标移出,继续动画

           3、滚动动画的速度可以自定义

           4、表格的高度固定

           5、向上滚动时,无限滚动,不存在卡顿

<template>

  <div

    class="scrolling-table-container"

    @mouseenter="pauseAnimation"

    @mouseleave="resumeAnimation"

  >

    <div class="table-wrapper" :style="{ height: tableHeight }">

      <el-table

        :data="displayData"

        :loading="loading"

        style="width: 100%"

        :show-header="showHeader"

        :row-key="rowKey"

        class="scrolling-table"

        :class="{

          'enable-scroll': needScroll,

          'is-paused': isPaused

        }"

      >

        <el-table-column

          v-for="column in columns"

          :key="column.prop"

          :prop="column.prop"

          :label="column.label"

          :width="column.width"

          :min-width="column.minWidth"

          :fixed="column.fixed"

        >

          <template #default="scope" v-if="column.hasSlot">

            <slot :name="column.prop" :row="scope.row" :index="scope.$index"></slot>

          </template>

        </el-table-column>

      </el-table>

    </div>

  </div>

</template>

<script setup lang="ts" name="ScrollingTable">

import { ref, computed, watch, onMounted, onBeforeUnmount } from 'vue'

import { ElTable, ElTableColumn } from 'element-plus'

interface TableColumn {

  prop: string

  label: string

  width?: string | number

  minWidth?: string | number

  fixed?: string | boolean

  hasSlot?: boolean

}

interface ScrollingTableProps {

  tableData: Record<string, unknown>[]

  columns: TableColumn[]

  loading?: boolean

  rowKey?: string

  showHeader?: boolean

  tableHeight?: string

  scrollThreshold?: number

  scrollSpeed?: number

  scrollDelay?: number

}

const props = withDefaults(defineProps<ScrollingTableProps>(), {

  loading: false,

  rowKey: 'id',

  showHeader: true,

  tableHeight: '250px',

  scrollThreshold: 8,

  scrollSpeed: 120,

  scrollDelay: 2000

})

const displayData = ref<Record<string, unknown>[]>([])

const isPaused = ref(false)

let delayTimer: number | null = null

// 计算是否需要滚动

const needScroll = computed(() => props.tableData.length > props.scrollThreshold)

// 计算动画持续时间

const animationDuration = computed(() => {

  if (!needScroll.value) return 0

  // 基于数据长度计算合适的动画时间,确保平滑滚动

  return Math.max(props.tableData.length * props.scrollSpeed, 3000)

})

// 初始化显示数据

const initDisplayData = () => {

  if (needScroll.value && props.tableData.length > 0) {

    // 为无缝滚动复制数据

    displayData.value = [

      ...props.tableData,

      ...props.tableData

    ]

  } else {

    displayData.value = [...props.tableData]

  }

}

// 启动动画(延迟)

const startAnimation = () => {

  if (!needScroll.value) return

  clearTimeout(delayTimer!)

  delayTimer = setTimeout(() => {

  }, props.scrollDelay)

}

// 停止所有定时器

const stopTimers = () => {

  if (delayTimer) {

    clearTimeout(delayTimer)

    delayTimer = null

  }

}

// 暂停动画

const pauseAnimation = () => {

  isPaused.value = true

}

// 恢复动画

const resumeAnimation = () => {

  isPaused.value = false

}

// 重新初始化

const reinitialize = () => {

  stopTimers()

  isPaused.value = false

  initDisplayData()

  startAnimation()

}

// 监听数据变化

watch(() => props.tableData, () => {

  reinitialize()

}, { immediate: true })

// 监听配置变化

watch([

  () => props.scrollThreshold,

  () => props.scrollSpeed,

  () => props.scrollDelay

], () => {

  reinitialize()

})

onMounted(() => {

  startAnimation()

})

onBeforeUnmount(() => {

  stopTimers()

})

// 暴露方法

defineExpose({

  reinitialize,

  needScroll,

  pauseAnimation,

  resumeAnimation

})

</script>

<style lang="scss" scoped>

.scrolling-table-container {

  cursor: default;

  :deep(.el-table thead){

    color: #242933 !important;

    font-weight: 500;

  }

  .table-wrapper {

    overflow: hidden;

    position: relative;

     :deep(.el-table thead th.el-table__cell) {

        background: #F8F9FA !important;

      }

  }

  .scrolling-table {

    // 基本样式

    :deep(.el-table__body-wrapper) {

      overflow: hidden !important;

     

      &::-webkit-scrollbar {

        display: none;

      }

    }

   

    :deep(.el-table__header-wrapper) {

      overflow-x: hidden;

    }

    :deep(.el-table thead){

      color: #242933 !important;

      font-weight: 500;

    }

    :deep(.el-table__row) {

      transition: none;

    }

   

    :deep(.el-table__body) {

      transition: none;

    }

   

    // 鼠标悬停样式

    :deep(.el-table__row):hover {

      background-color: #f5f7fa;

    }

   

    // 启用滚动时的动画

    &.enable-scroll :deep(.el-table__body) {

      animation: scroll-up v-bind("animationDuration + 'ms'") linear infinite;

      animation-delay: v-bind("scrollDelay + 'ms'");

    }

   

    // 暂停状态

    &.is-paused :deep(.el-table__body) {

      animation-play-state: paused;

    }

  }

}

// 滚动动画关键帧 - 无限向上滚动

@keyframes scroll-up {

  0% {

    transform: translateY(0);

  }

  100% {

    transform: translateY(-50%);

  }

}

// 响应式优化

@media (prefers-reduced-motion: reduce) {

  .scrolling-table.enable-scroll :deep(.el-table__body) {

    animation: none;

  }

}

</style>

相比liMarquee,优点如下:

1、不用使用npm 安装liMarquee包

2、liMarquee是基于jquery的,使用liMarquee,还得安装jquery

3、使用js、css 实现动画效果,性能友好

http://www.dtcms.com/a/404300.html

相关文章:

  • 代理分佣后台网站开发安徽住房和城乡建设厅官网
  • 微网站用什么做天津工程建设信息网站
  • 网站制造做网站流量
  • 南昌网站开发培训学校全媒体运营师报考条件
  • 站长工具下载app智能云建站
  • 做网站应该会什么问题建设一个网站需要哪些方面的开支
  • 宁德住房和城乡建设部网站东莞创建网站
  • 网站做微信链接怎么做的建设网站的知识竞赛
  • 上海好的高端网站建设服务公司网站建设一站式
  • 网站百度秒收自助建站管理平台
  • 网站建设的机构2022年企业所得税政策
  • 手机网站建设维护网络叶子 网站推广
  • 公司网站建设的方案网站建设网站
  • 北京通州个人网站建设桐柏网站
  • 西安房产网站大全wordpress手机版中文
  • 做网站的目标wordpress 字符转义
  • 婚恋网站女代我做彩票二维码自动生成
  • 局域网建站软件上海公司企业查询
  • 马鞍山做网站的福州搜索优化技术
  • 哪个网站可以学做包子电子商务网站规划的原则
  • 仿it资讯类网站源码王烨当兵小说
  • 智慧外贸平台|基于Java+vue的智慧外贸平台系统(源码+数据库+文档)
  • 爱站网长尾关键词挖掘工具微信小程序怎么加入我的小程序
  • pxcharts多维表格编辑器Ultra版:支持二开 + 本地化部署的多维表格解决方案
  • 网站安全管理机制建设建设银行德阳分行网站
  • php网站数据库怎么上传做网站的专业
  • 做公司网站应准备什么材料淮安建设局网站
  • 河北唐山网站建设商务网站开发与建设
  • python 做网站合适吗网站的命名规则
  • 网站开发与设计实训报告1000字网站如何做百度权重