0.0.4 • Published 1 year ago

w-scroll v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
1 year ago

无限滚动组件

介绍

基于vue3+Typescript封装的无限滚动组件,支持垂直(上下)和水平滚动(左右) 本组件是基于vue3和TS进行开发,暂不支持vue2

vue

开始使用

安装

npm install w-scroll -S

引入

在main.ts中引入

import { createApp } from 'vue'
import App from './App.vue'
import WScroll from 'w-scroll'

const app = createApp(App)
app.use(WScroll)
app.mount('#app')

使用

<script setup lang="ts">

</script>
<template>
  <div style="width: 500px; border: 1px solid #000;">
    <w-scroll>
      <template #content>
        <ul>
          <li>Lorem ipsum dolor sit amet consectetur.</li>
          <li>Saepe obcaecati ab excepturi qui voluptate.</li>
          <li>Optio dicta consequatur vero vel quis.</li>
          <li>Tenetur eum labore libero excepturi ab.</li>
          <li>Totam ea quaerat id consequatur animi!</li>
          <li>Esse praesentium fuga officiis vero iste.</li>
          <li>Necessitatibus quia quidem itaque commodi consectetur?</li>
          <li>A dicta odit cumque saepe aliquid.</li>
          <li>Ad, aspernatur quod! Reprehenderit, corporis labore!</li>
          <li>Commodi voluptatum reprehenderit ipsa eligendi! Aspernatur.</li>
          <li>Iure tenetur sapiente labore esse distinctio.</li>
          <li>Illo ducimus error explicabo quibusdam ratione?</li>
          <li>Lorem ipsum dolor sit amet consectetur adipisicing.</li>
          <li>Ab beatae tenetur autem? Aspernatur, dolorem natus?</li>
          <li>Sapiente repellendus quisquam nostrum architecto aliquam velit.</li>
          <li>Eveniet possimus quas molestias velit culpa dolorem!</li>
          <li>Eligendi quidem, expedita ea debitis rem libero.</li>
          <li>Provident, sunt. Dolores eum amet voluptatibus consequuntur!</li>
          <li>Vel enim odit magnam consectetur voluptas ratione.</li>
          <li>Error, excepturi iste illo eligendi quae possimus?</li>
          <li>Aperiam dolore labore voluptatibus, a fugiat cupiditate!</li>
          <li>
            Repellendus autem, veritatis exercitationem accusantium doloribus
            tempore!
          </li>
          <li>
            Exercitationem, ullam voluptatem recusandae asperiores perspiciatis
            aliquam.
          </li>
          <li>Error delectus voluptatum aut eligendi explicabo repudiandae?</li>
        </ul>
      </template>
    </w-scroll>
  </div>
</template>

属性

属性名描述类型默认值
scroll是否开启滚动,适用于页面挂载时DOM已生成的情况,动态创建DOM请使用start方法Booleantrue
speed滚动速度。是按单位像素进行滚动,可选 0-无穷,建议是0-2之间Number0.5
mode滚动模式。是垂直滚动(上下)还是水平滚动(左右),可选 horizontalStringvertical
direction滚动方向。可选值 bottom/left/rightStringtop
mouseEvent是否开启鼠标移入移除事件,移入暂停滚动,移除继续滚动Booleantrue
copy是否自动复制出和原内容一样的节点,用于实现无缝滚动的效果Booleantrue

方法

方法名描述参数
start()手动开启滚动,使用此方法时属性scroll最好设置为false
stop(isReset)手动停止滚动,参数isReset表示是否停止滚动后是否恢复初始位置,并移除鼠标移入和移除事件Boolean,默认值true

插槽

名称描述
content需要滚动的内容

滚动区域的样式,完全由父元素觉得,滚动组件的宽高继承自父元素没有复杂的样式配置,如果是垂直滚动一定要设置父元素高度,否则不生效,如果是水平滚动一定要设置父元素的宽度,否则不生效。

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago