1.1.4 • Published 7 months ago

@joyday/vue-loop-scroll v1.1.4

Weekly downloads
-
License
MIT
Repository
github
Last release
7 months ago

Vue Loop Scroll

Commitizen friendly

中文 | English

🚀 特性

  • 🔥 超大数据流畅滚动
    • 即使 10 万条数据,也能丝滑滚动不卡顿!仅渲染可视区域的 2 倍数据,大幅减少 DOM 负担,让滚动更流畅。
  • 🌟 适应变化,始终顺滑
    • 支持容器大小动态调整,即使数据实时更新,依然能保持平滑滚动,提供最佳用户体验。
  • 🔧 灵活滚动控制
    • 支持四向滚动、单步停顿、滚动速度调节、鼠标悬停控制等多种配置,让滚动更符合需求。

文档

https://joydayX.github.io/website-vue-loop-scroll/

📦 安装

# npm
npm i @joyday/vue-loop-scroll
# pnpm
pnpm i @joyday/vue-loop-scroll
# yarn
yarn add @joyday/vue-loop-scroll

示例

1. 四个方向滚动

Scroll in Direction Up

Scroll in Direction Down

Scroll in Direction Left

Scroll in Direction Right

2. 滚动停顿

单步滚动暂停

Step-by-Step Pause-1

Step-by-Step Pause-2

翻页滚动暂停

Step-by-Step Pause-3

3. 自适应视口大小 & 动态数据更新

Responsive Viewport & Dynamic Data Update

🦄 使用

1. 基础用法

组件的基本使用方法。

<script setup lang="ts">
  import { ref } from "vue";
  import { LoopScroll } from "@joyday/vue-loop-scroll";

  const dataSource = ref([
    "1. scrolling scrolling scrolling",
    "2. scrolling scrolling scrolling",
    "3. scrolling scrolling scrolling",
    "4. scrolling scrolling scrolling",
  ]);
</script>

<template>
  <div class="box">
    <LoopScroll :dataSource></LoopScroll>
  </div>
</template>

<style scoped>
  .box {
    height: 150px;
    border: 1px solid red;
    :deep(.scroll-loop-item) {
      border-bottom: 1px dashed #000;
      padding: 10px 4px;
    }
  }
</style>

2. 自定义用法

可以使用插槽自定义渲染内容。

<script setup lang="ts">
  import { ref } from "vue";
  import { LoopScroll } from "@joyday/vue-loop-scroll";

  const dataSource = ref([
    "1. scrolling scrolling scrolling",
    "2. scrolling scrolling scrolling",
    "3. scrolling scrolling scrolling",
    "4. scrolling scrolling scrolling",
  ]);
</script>

<template>
  <div class="box">
    <LoopScroll :dataSource>
      <template #default="{ item }">
        <span style="color: green">{{ item }}</span>
      </template>
    </LoopScroll>
  </div>
</template>

<style scoped>
  .box {
    height: 150px;
    border: 1px solid red;
    :deep(.scroll-loop-item) {
      border-bottom: 1px dashed #000;
      padding: 10px 4px;
    }
  }
</style>

3. 高级用法

可以配置滚动方向、单步暂停时间,并为数据项指定唯一标识键。

<script setup lang="ts">
  import { ref } from "vue";
  import { LoopScroll } from "@joyday/vue-loop-scroll";

  const dataSource = ref(
    Array.from({ length: 4 }, (_, index) => ({
      id: index + 1,
      value: "scrolling scrolling",
    })),
  );
</script>

<template>
  <div class="box">
    <LoopScroll :dataSource itemKey="id" direction="left" :waitTime="1000">
      <template #default="{ item }">
        <span>{{ item.id }}.{{ item.value }}</span>
      </template>
    </LoopScroll>
  </div>
</template>

<style scoped>
  .box {
    border: 1px solid red;
    width: 500px;
    :deep(.scroll-loop-item) {
      padding: 10px;
    }
  }
</style>

贡献指南

欢迎参与贡献!请阅读贡献指南了解详情。

开源协议

本项目基于 MIT 协议 授权。

1.1.4

7 months ago

1.1.4-rc.0

7 months ago

1.1.3

7 months ago

1.1.2

7 months ago

1.1.1

8 months ago

1.1.1-rc.0

8 months ago

1.1.0

8 months ago

1.1.0-rc.1

8 months ago

1.1.0-rc.0

8 months ago

1.0.2

8 months ago

1.0.1

8 months ago

1.0.0

8 months ago

1.0.0-rc.0

8 months ago