2.8.6 • Published 17 days ago

vue-virtual-draglist v2.8.6

Weekly downloads
-
License
MIT
Repository
github
Last release
17 days ago

vue-virtual-draglist

npm npm vue2

A virtual scrolling list component that can be sorted by dragging, for vue3

Live demo

Simple usage

npm i vue-virtual-draglist@next -D

Root component:

<template>
  <div>
    <virtual-list
      style="height: 360px; overflow-y: auto;" // make list scrollable
      :data-key="'id'"
      :data-source="items"
    >
      <template slot="item" slot-scope="{ record, index, dataKey }">
        <span>{{ record.text }}</span>
      </template>
    </virtual-list>
  </div>
</template>

<script setup lang="ts">
import VirtualList from 'vue-virtual-draglist';

const items = ref([{id: '1', text: 'abc'}, {id: '2', text: 'def'}]);
</script>

Emits

EmitDescription
topEvent fired when scroll to top
bottomEvent fired when scroll to bottom
ondragstartEvent fired when the drag is started, (list, from, node) => {}
ondragendEvent fired when the drag is completed, (list, from, to, changed) => {}

Props

Required props

PropTypeDescription
data-keyStringThe unique identifier of each piece of data, in the form of 'a.b.c'
data-sourceArraydata list

Optional props

Commonly used

PropTypeDefaultDescription
keepsNumber30The number of lines rendered by the virtual scroll
sizeNumber-The estimated height of each piece of data, you can choose to pass it or not, it will be automatically calculated
directionStringverticalvertical/horizontal, scroll direction
draggableFunction/String-Specifies which items inside the element should be draggable
animationNumber150Animation speed moving items when sorting
keepOffsetBooleanfalseWhen scrolling up to load data, keep the same offset as the previous scroll
autoScrollBooleantrueAutomatic scrolling when moving to the edge of the container, for browsers that do not support HTML5 drag events
scrollStepNumber5The distance to scroll each frame when autoscrolling
scrollThresholdNumber15Threshold to trigger autoscroll

Uncommonly used

PropTypeDefaultDescription
disabledBooleanfalseDisables the sortable if set to true
delayNumber10Delay time of debounce function
rootTagStringdivLabel type for root element
wrapTagStringdivLabel type for list wrap element
itemTagStringdivLabel type for list item element
headerTagStringdivLabel type for header slot element
footerTagStringdivLabel type for footer slot element
wrapClassString''List wrapper element class
wrapStyleObject{}List wrapper element style
itemClassString''List item element class
itemStyleObject{}List item element style
ghostClassString''The class of the mask element when dragging
ghostStyleObject{}The style of the mask element when dragging
chosenClassString''The class of the selected element when dragging

Methods

MethodDescription
reset()Reset to initial
getSize(key)Get the size of the current item by unique key value
getOffset()Get the current scroll height
scrollToTop()Scroll to top of list
scrollToBottom()Scroll to bottom of list
scrollToIndex(index)Scroll to the specified index position
scrollToOffset(offset)Scroll to the specified offset

License

MIT License.

3.2.3

17 days ago

2.8.6

18 days ago

3.2.2

2 months ago

2.8.5

2 months ago

3.2.1

2 months ago

2.8.4

2 months ago

3.2.0

4 months ago

2.8.3

4 months ago

2.8.2

4 months ago

2.8.1

4 months ago

2.8.0

4 months ago

2.7.4

10 months ago

3.1.4

10 months ago

2.6.16

1 year ago

2.6.17

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

2.7.3

12 months ago

2.7.0

1 year ago

2.7.2

12 months ago

2.7.1

1 year ago

3.1.3

12 months ago

3.1.2

12 months ago

3.1.1

1 year ago

3.1.0

1 year ago

2.6.15

2 years ago

2.6.3

2 years ago

2.6.2

2 years ago

2.6.11

2 years ago

2.6.12

2 years ago

2.6.13

2 years ago

2.6.14

2 years ago

2.6.10

2 years ago

3.0.1

2 years ago

3.0.0

2 years ago

2.6.5

2 years ago

2.6.4

2 years ago

2.6.7

2 years ago

2.6.6

2 years ago

2.6.9

2 years ago

2.6.8

2 years ago

2.6.1

2 years ago

2.6.0

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.5.0

2 years ago

2.4.1

2 years ago

2.4.0

2 years ago

2.5.2

2 years ago

2.5.1

2 years ago

2.4.2

2 years ago

2.1.10

2 years ago

2.1.9

2 years ago

2.1.8

2 years ago

2.1.7

2 years ago

2.1.6

2 years ago

2.1.5

2 years ago

2.1.4

2 years ago

2.1.3

2 years ago

2.1.2

2 years ago

2.1.1

2 years ago

2.1.0

2 years ago

2.0.9

2 years ago

2.0.8

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.3

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago