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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@xiaohaih/drag

v1.0.0-beta.3

Published

拖拽插件, 可通过指令或函数调用来拖拽元素移动

Downloads

14

Readme

拖拽插件

  • 支持 vue2.7.* vue3

在线demo

使用示例

  1. 指令形式
<template>
    <div>
        <div v-draggable class="box absolute cursor-move">
            拖拽我
        </div>
        <div class="wrap relative size-600px">
            <div v-draggable.overflow="'.handle'" class="box absolute left-300px w-100px h-100px">
                <div class="handle cursor-move">
                    拖拽我
                </div>
                <div>内容1</div>
                <div>内容2</div>
                <div>内容3</div>
                <div>内容4</div>
            </div>
        </div>
        <div v-draggable="draggableOption" class="wrap">
            <div class="box absolute left-50px top-800px">
                <div class="handle cursor-move">
                    拖拽我
                </div>
                <div>内容1</div>
                <div>内容2</div>
                <div>内容3</div>
                <div>内容4</div>
            </div>
        </div>
    </div>
</template>

<script lang="ts" setup>
import { draggable as vDraggable } from '@xiaohaih/drag';

const draggableOption = {
    target: '.box',
    handle: '.handle',
};
</script>
  1. 通过函数调用
import { drag } from '@xiaohaih/drag';

drag({ target: document.querySelector('.box') });
drag({
    target: document.querySelectorAll('.box')[1],
    handle: document.querySelectorAll('.box')[1].querySelector('.handle'),
    overflow: true,
});

API

  • @param {object} option 传递的参数
  • @param {HTMLElement | ((el: HTMLElement) => HTMLElement) | string} option.target 拖拽目标元素
  • @param {HTMLElement | ((el: HTMLElement) => HTMLElement) | string} [option.handle] 拖拽句柄()
  • @param {boolean} [option.disabled] 是否禁用
  • @param {boolean} [option.overflow] 是否可以拖拽溢出(超出父级元素)
  • @param {boolean} [option.side] 是否强制靠边
  • @param {boolean} [option.left] 开启强制靠边时, 是否强制显示在左侧
  • @param {boolean} [option.right] 开启强制靠边时, 是否强制显示在右侧
  • @param {(axis: Record<'x' | 'y', number>, axisPercent: Record<'x' | 'y', number>) => void} [option.siteUpdated] 拖拽位置更新时触发