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

ddrag

v1.0.14

Published

a drag package

Readme

ddrag

一个快速实现拖拽功能的插件

非常方便实现拖拽,只需要一句js代码 也可在移动端中使用

demo

查看demo

安装

npm install ddrag --save;

引入

import Ddrag from 'ddrag'

初始化

var option = {
    el: '#myDrag', // 必填项,传入id或者类名,'.myDrag', 拖拽区域元素
    targetEl: '#parent', // 可选项,实际拖拽元素,默认为 el。此元素必须是 el 的父元素, 或者是 el 元素自身
    left: '100px', // 可选项,设置初始位置,也可为百分比:'30%',也可填'left','center','right',不配置默认为原始文档流中的位置
    top: '100px', // 可选项,设置初始位置,也可为百分比:'30%',也可填'top','middle','bottom',不配置默认为原始文档流中的位置
    zIndex: '20', // 可选项,拖拽对象的z-index值
    marginLeft: '10px', // 可选项,拖拽的范围限制,拖距离左边的边界值,默认为0
    marginTop: '20', // 可选项,拖拽距离上边的边界值
    marginRight: '10', // 可选项,拖拽距离右边的边界值
    marginBottom: '20px', // 可选项,拖拽距离下边的边界值
    stop: false, // 可选项,是否暂时禁止拖拽,默认false,为true时,拖拽功能失效
    draging: function () {}, // 可选项,拖拽中的回调函数
    afterDrag: function () {}, // 可选项,每次拖拽后的回调函数
    cursor: 'pointer', // 可选项,鼠标放在可拖拽区域中时的光标形状,默认为 move
}
var myDdrag = new Ddrag(option);

初始化后可通过 set 方法改变初始化时的参数:

myDdrag.set({
    marginLeft: '20px',
    left: '10px',
    stop: true, // 暂时禁止拖拽功能
    draging: false, // false 可以取消对应的回调函数
    afterDrag: function () {}
})

可通过以下属性获得拖拽对象的信息:

myDdrag.top; // 100, 拖拽对象距窗口顶边的距离
myDdrag.left; // 100, 拖拽对象距窗口左边的距离
myDdrag.lastTop; // 拖拽对象上一次位置距窗口顶边的距离
myDdrag.lastLeft; // 拖拽对象上一次位置距窗口左边的距离

可通过destroy方法来销毁:

myDdrag.destroy() // DOM 对象将保持销毁前的位置
myDdrag.destory(true) // DOM 对象回到原始的文档流中