Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

vue-virtual-draglist

Package Overview
Dependencies
Maintainers
1
Versions
101
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vue-virtual-draglist

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

  • 2.6.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
362
decreased by-31.83%
Maintainers
1
Weekly downloads
 
Created
Source

Downloads Version

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

Simple usage

npm i vue-virtual-draglist -D

Root component:

<template>
  <div>
    <virtual-drag-list
      :data-key="'id'"
      :data-source="list"
      :draggable="'.drag'"
      @top="handleToTop"
      @bottom="handleToBottom"
      @ondragend="ondragend"
    >
      <template slot="item" slot-scope="{ record, index, dataKey }">
        <span class="drag">{{ record.id }}</span>
        {{ record.text }}
      </template>
      <template slot="header">
        <div class="loading">top loading...</div>
      </template>
      <template slot="footer">
        <div class="loading">bottom loading...</div>
      </template>
    </virtual-drag-list>
  </div>
</template>

<script>
  import virtualDragList from 'vue-virtual-draglist'

  export default {
    name: 'root',
    data () {
      return {
        list: [{id: '1', text: 'asd'}, {id: '2', text: 'fgh'}, ...]
      }
    },
    components: { virtualDragList },
    methods: {
      handleToTop() {
        ...
      },
      handleToBottom() {
        ...
      },
      ondragend(list, from, to, changed) {
        console.log(list, from, to, changed)
      }
    }
  }
</script>

Emits

emitDescription
topevent fired when scroll to top
bottomevent fired when scroll to bottom
ondragendevent fired when the drag is complete

Props type

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
sizeNumber50The estimated height of each piece of data, you can choose to pass it or not, it will be automatically calculated
directionStringverticalvertical/horizontal, scroll direction
disabledBooleanfalseDisables the sortable if set to true
draggableFunction/StringundefinedSpecifies which items inside the element should be draggable, the function type must return a boolean
draggingFunctionundefinedSpecifies the drag element, which must return an HTMLElement: (e) => e.target

Uncommonly used

PropTypeDefaultDescription
animationNumber150Animation time
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
rootClassString''Root element class
rootStyleObject{}Root element style
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

Public methods

Use ref to get the method inside the component

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

Keywords

FAQs

Package last updated on 26 May 2022

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc