npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vue-drag-2.0

v1.5.0

Published

vue drag sort vue2.0

Downloads

15

Readme

Vue-dragable

适用于vue2.0

NPM

github: https://github.com/ppya0812/vue-dragable

使用方法

NPM安装

npm install vue-drag
	

页面调用

<template>
	<div v-sortable="{onUpdate: onUpdate, preventOnFilter: false}" class="drag-list">
		<div v-for="v in list" :key="v" class="drag-item">
		</div>
	</div>
</template>
<script>
import Vue from 'vue'
import Drag from '@/wm-kit/packages/drag/src/vueDrag'

Vue.use(Drag)
export default {
	data() {
		return {
	    list: ['Foo', 'Bar', 'Baz']
		}
  },
  methods: {
    onUpdate: function (event) {
      this.list.splice(event.newIndex, 0, this.list.splice(event.oldIndex, 1)[0])
    }
  }
}
</script>

使用示例

<template>
	<div v-sortable="{onUpdate: onUpdate, preventOnFilter: false}" class="drag-list">
		<div v-for="v in list" :key="v" class="drag-item">
			{{v}}
		</div>
	</div>
</template>

<script>
import Vue from 'vue'
import Drag from '@/wm-kit/packages/drag/src/vueDrag'

Vue.use(Drag)
export default {
	data() {
		return {
	    list: ['Foo', 'Bar', 'Baz']
		}
  },
  methods: {
    onUpdate: function (event) {
      this.list.splice(event.newIndex, 0, this.list.splice(event.oldIndex, 1)[0])
    }
  }
}

</script>

<style>
	.drag-list {
		border: 1px solid #f6f6f6;
		width: 50%;
	}
	.drag-item {
		border-top: 1px solid #f6f6f6;
		height: 30px;
		line-height: 30px;
		background: #ccc;
	}
	.sortable-chosen {
		background: #f5f5f5;
	}

</style>

API 属性介绍 Attributes:

name | type | default | description --------------- | -------------: | :--------: | :--------------------------------------------------------: group | String | 'name' | or { name: "...", pull: [true, false, clone], put: [true, false, array] } delay | number | 0 | 延迟时间 time in milliseconds to define when the sorting should start sort | Boolean | true | 是否排序sorting inside list disabled | Boolean | false | drag功能失效Disables the sortable if set to trueshould start animation | Boolean | 150 | ms, animation speed moving items when sorting, 0 — without animation preventOnFilter | Boolean | true | 不阻止非filter区域的默认事件 Call event.preventDefault() when triggered filter store | Object | null | @see Store handle | String | '.my-handle' |Drag handle selector within list itemsfilter filter | String| ".ignore-elements" | 过滤不拖拽的元素 Selectors that do not lead to dragging (String or Function) should filter draggable | String| ".item" |Specifies which items inside the element should be draggable ghostClass | String| "sortable-ghost"| // Class name for the drop placeholder chosenClass | String| "sortable-chosen" | // Class name for the chosen item dragClass | String| "sortable-drag"| // Class name for the dragging item dataIdAttr | String| 'data-id'| forceFallback | String| false| // ignore the HTML5 DnD behaviour and force the fallback to kick in fallbackClass | String| "sortable-fallback"| // Class name for the cloned DOM Element when using forceFallback fallbackOnBody | String| false| // Appends the cloned DOM Element into the Document's Body fallbackTolerance | String| 0| // Specify in pixels how far the mouse should move before it's considered as a drag.
scroll | String| true| // or HTMLElement scrollFn | String| function(offsetX, offsetY, originalEvent) { ... }| // if you have custom scrollbar scrollFn may be used for autoscrolling scrollSensitivity | String| 30| // px, how near the mouse must be to an edge to start scrolling. scrollSpeed | String| 10| // px

函数api

1.setData

function (/** DataTransfer */dataTransfer, /** HTMLElement*/dragEl) {
	dataTransfer.setData('Text', dragEl.textContent); // `dataTransfer` object of HTML5 DragEvent
}

2. onChoose:

function (/**Event*/evt) {
	evt.oldIndex;  // element index within parent
}

3. onStart:

// Element dragging started

function (/**Event*/evt) {
	evt.oldIndex;  // element index within parent
}

4. onEnd:

// Element dragging ended
function (/**Event*/evt) {
	evt.oldIndex;  // element's old index within parent
	evt.newIndex;  // element's new index within parent
},

5. onAdd:

// Element is dropped into the list from another list
function (/**Event*/evt) {
	var itemEl = evt.item;  // dragged HTMLElement
	evt.from;  // previous list
	// + indexes from onEnd
},

6. onUpdate:

// Changed sorting within list
function (/**Event*/evt) {
	var itemEl = evt.item;  // dragged HTMLElement
	// + indexes from onEnd
},

7. onSort:

// Called by any change to the list (add / update / remove)
function (/**Event*/evt) {
	// same properties as onUpdate
},

8. onRemove:

// Element is removed from the list into another list
function (/**Event*/evt) {
	// same properties as onUpdate
},

9. onFilter:

// Attempt to drag a filtered element
function (/**Event*/evt) {
	var itemEl = evt.item;  // HTMLElement receiving the `mousedown|tapstart` event.
},

10. onMove:

// Event when you move an item in the list or between lists
function (/**Event*/evt, /**Event*/originalEvent) {
	// Example: http://jsbin.com/tuyafe/1/edit?js,output
	evt.dragged; // dragged HTMLElement
	evt.draggedRect; // TextRectangle {left, top, right и bottom}
	evt.related; // HTMLElement on which have guided
	evt.relatedRect; // TextRectangle
	originalEvent.clientY; // mouse position
	// return false; — for cancel
},

11. onClone:

// Called when creating a clone of element
function (/**Event*/evt) {
	var origEl = evt.item;
	var cloneEl = evt.clone;
}