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

simple-dragdrop

v2.0.4

Published

A simple Drag&Drop like component based on Simple Module

Downloads

6

Readme

Simple Dragdrop

Circle CI

一个简单的Drag&Drop组件,用来替代D&D API。

依赖项:

使用方法

首先,需要在页面里引用相关脚本以及css

<script type="text/javascript" src="path/to/jquery.min.js"></script>
<script type="text/javascript" src="path/to/module.js"></script>
<script type="text/javascript" src="path/to/dragdrop.js"></script>

通过dragdrop方法,实例化dragdrop对象

simple.dragdrop({
    el: '.wrapper-1',
    draggable: '.box',
    droppable: '.droparea'
});

API 文档

####初始化选项

el

可选,dragdrop的容器元素,默认为document(dragdrop对象会绑定到el上)。

draggable

必选,可以被drag的元素的选择符selector string

droppable

必选,可以被drop的元素的选择符selector string

helper

可选,拖拽的helper元素,可以是Dom/function,如果为空则为原元素。

placeholder

可选,开始拖动之后被拖拽元素会隐藏,显示placeholder,可以是Dom/function,如果为空,则是一个空白的占位元素

cursorPosition

可选,确定helper的相对于鼠标的位置,默认为'auto',还可以为'center'(中心), 'cornor'(左上角)

cursorOffset

可选,对helper位置进行微调,需要传入top以及left

axis

可选,拖拽的方向,默认为'both', 可以为'x', 'y'

方法

destroy()

销毁dragdrop对象,还原初始环境

事件

dragstart opts: dragging, helper, placeholder

当拖拽发生时触发

dragenter opts: dragging, target, helper, placeholder

当被拖拽元素进入可以放置区域时触发

dragleave opts: dragging, target, helper, placeholder

当被拖拽元素离开可以放置区域时触发

drag opts: dragging, helper, placeholder

被拖拽的时候,持续触发

before-dragend opts: dragging, helper, placeholder

当拖拽结束前触发,此时,helper以及placeholder都没有被移除

dragend opts: dragging

当拖拽结束的时候触发,此时,helper以及placeholder已经被移除

drop opts: dragging, target

当拖拽元素放置到可放置区域时触发

destroy

当组件销毁时触发