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

drag-drop

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

drag-drop - npm Package Compare versions

Comparing version 2.6.0 to 2.7.0

2

dragdrop.min.js

@@ -1,1 +0,1 @@

!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.DragDrop=n()}}(function(){return function n(e,t,r){function o(u,f){if(!t[u]){if(!e[u]){var a="function"==typeof require&&require;if(!f&&a)return a(u,!0);if(i)return i(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var s=t[u]={exports:{}};e[u][0].call(s.exports,function(n){var t=e[u][1][n];return o(t?t:n)},s,s.exports,n,e,t,r)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(n,e,t){function r(){s=!1,f.length?c=f.concat(c):l=-1,c.length&&o()}function o(){if(!s){var n=setTimeout(r);s=!0;for(var e=c.length;e;){for(f=c,c=[];++l<e;)f&&f[l].run();l=-1,e=c.length}f=null,s=!1,clearTimeout(n)}}function i(n,e){this.fun=n,this.array=e}function u(){}var f,a=e.exports={},c=[],s=!1,l=-1;a.nextTick=function(n){var e=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)e[t-1]=arguments[t];c.push(new i(n,e)),1!==c.length||s||setTimeout(o,0)},i.prototype.run=function(){this.fun.apply(null,this.array)},a.title="browser",a.browser=!0,a.env={},a.argv=[],a.version="",a.versions={},a.on=u,a.addListener=u,a.once=u,a.off=u,a.removeListener=u,a.removeAllListeners=u,a.emit=u,a.binding=function(n){throw new Error("process.binding is not supported")},a.cwd=function(){return"/"},a.chdir=function(n){throw new Error("process.chdir is not supported")},a.umask=function(){return 0}},{}],2:[function(n,e,t){e.exports=function(n,e){function t(n,r){return n.reduce(function(n,o){return Array.isArray(o)&&e>r?n.concat(t(o,r+1)):n.concat(o)},[])}return e="number"==typeof e?e:1/0,e?t(n,1):Array.isArray(n)?n.map(function(n){return n}):n}},{}],3:[function(n,e,t){(function(n){e.exports=function(e,t){function r(e){function r(){t&&t(e,i),t=null}a?n.nextTick(r):r()}function o(n,e,t){i[n]=t,(0===--u||e)&&r(e)}var i,u,f,a=!0;Array.isArray(e)?(i=[],u=e.length):(f=Object.keys(e),i={},u=f.length),u?f?f.forEach(function(n){e[n](o.bind(void 0,n))}):e.forEach(function(n,e){n(o.bind(void 0,e))}):r(null),a=!1}}).call(this,n("_process"))},{_process:1}],"/":[function(n,e,t){function r(n,e){"string"==typeof n&&(n=window.document.querySelector(n));var t=i(n),r=u(n),a=f(n,e);return n.addEventListener("dragenter",o,!1),n.addEventListener("dragover",t,!1),n.addEventListener("dragleave",r,!1),n.addEventListener("drop",a,!1),function(){n instanceof window.Element&&n.classList.remove("drag"),n.removeEventListener("dragenter",o,!1),n.removeEventListener("dragover",t,!1),n.removeEventListener("dragleave",r,!1),n.removeEventListener("drop",a,!1)}}function o(n){return n.stopPropagation(),n.preventDefault(),!1}function i(n){return function(e){return e.stopPropagation(),e.preventDefault(),n instanceof window.Element&&n.classList.add("drag"),e.dataTransfer.dropEffect="copy",!1}}function u(n){return function(e){return e.target===n?(e.stopPropagation(),e.preventDefault(),n instanceof window.Element&&n.classList.remove("drag"),!1):void 0}}function f(n,e){return function(t){t.stopPropagation(),t.preventDefault(),n instanceof window.Element&&n.classList.remove("drag");var r={x:t.clientX,y:t.clientY};if(t.dataTransfer.items){var o=c(t.dataTransfer.items).filter(function(n){return"file"===n.kind});if(0===o.length)return;l(o.map(function(n){return function(e){a(n.webkitGetAsEntry(),e)}}),function(n,t){if(n)throw n;e(s(t),r)})}else{var i=c(t.dataTransfer.files);if(0===i.length)return;i.forEach(function(n){n.fullPath="/"+n.name}),e(i,r)}return!1}}function a(n,e){function t(){i.readEntries(function(n){n.length>0?(o=o.concat(c(n)),t()):r()})}function r(){l(o.map(function(n){return function(e){a(n,e)}}),e)}var o=[];if(n.isFile)n.file(function(t){t.fullPath=n.fullPath,e(null,t)},function(n){e(n)});else if(n.isDirectory){var i=n.createReader();t()}}function c(n){return Array.prototype.slice.call(n||[],0)}e.exports=r;var s=n("flatten"),l=n("run-parallel")},{flatten:2,"run-parallel":3}]},{},[])("/")});
!function(n){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=n();else if("function"==typeof define&&define.amd)define([],n);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.DragDrop=n()}}(function(){return function n(e,r,t){function o(a,f){if(!r[a]){if(!e[a]){var u="function"==typeof require&&require;if(!f&&u)return u(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var s=r[a]={exports:{}};e[a][0].call(s.exports,function(n){var r=e[a][1][n];return o(r?r:n)},s,s.exports,n,e,r,t)}return r[a].exports}for(var i="function"==typeof require&&require,a=0;a<t.length;a++)o(t[a]);return o}({1:[function(n,e,r){function t(){s=!1,f.length?c=f.concat(c):l=-1,c.length&&o()}function o(){if(!s){var n=setTimeout(t);s=!0;for(var e=c.length;e;){for(f=c,c=[];++l<e;)f&&f[l].run();l=-1,e=c.length}f=null,s=!1,clearTimeout(n)}}function i(n,e){this.fun=n,this.array=e}function a(){}var f,u=e.exports={},c=[],s=!1,l=-1;u.nextTick=function(n){var e=new Array(arguments.length-1);if(arguments.length>1)for(var r=1;r<arguments.length;r++)e[r-1]=arguments[r];c.push(new i(n,e)),1!==c.length||s||setTimeout(o,0)},i.prototype.run=function(){this.fun.apply(null,this.array)},u.title="browser",u.browser=!0,u.env={},u.argv=[],u.version="",u.versions={},u.on=a,u.addListener=a,u.once=a,u.off=a,u.removeListener=a,u.removeAllListeners=a,u.emit=a,u.binding=function(n){throw new Error("process.binding is not supported")},u.cwd=function(){return"/"},u.chdir=function(n){throw new Error("process.chdir is not supported")},u.umask=function(){return 0}},{}],2:[function(n,e,r){e.exports=function(n,e){function r(n,t){return n.reduce(function(n,o){return Array.isArray(o)&&e>t?n.concat(r(o,t+1)):n.concat(o)},[])}return e="number"==typeof e?e:1/0,e?r(n,1):Array.isArray(n)?n.map(function(n){return n}):n}},{}],3:[function(n,e,r){(function(n){e.exports=function(e,r){function t(e){function t(){r&&r(e,i),r=null}u?n.nextTick(t):t()}function o(n,e,r){i[n]=r,(0===--a||e)&&t(e)}var i,a,f,u=!0;Array.isArray(e)?(i=[],a=e.length):(f=Object.keys(e),i={},a=f.length),a?f?f.forEach(function(n){e[n](o.bind(void 0,n))}):e.forEach(function(n,e){n(o.bind(void 0,e))}):t(null),u=!1}}).call(this,n("_process"))},{_process:1}],"/":[function(n,e,r){function t(n,e){"string"==typeof n&&(n=window.document.querySelector(n)),"function"==typeof e&&(e={onDrop:e});var r=i(n,e.onDragOver),t=a(n,e.onDragLeave),u=f(n,e.onDrop,e.onDragLeave);return n.addEventListener("dragenter",o,!1),n.addEventListener("dragover",r,!1),n.addEventListener("dragleave",t,!1),n.addEventListener("drop",u,!1),function(){n instanceof window.Element&&n.classList.remove("drag"),n.removeEventListener("dragenter",o,!1),n.removeEventListener("dragover",r,!1),n.removeEventListener("dragleave",t,!1),n.removeEventListener("drop",u,!1)}}function o(n){return n.stopPropagation(),n.preventDefault(),!1}function i(n,e){return function(r){return r.stopPropagation(),r.preventDefault(),e&&e(),n instanceof window.Element&&n.classList.add("drag"),r.dataTransfer.dropEffect="copy",!1}}function a(n,e){return function(r){if(r.target!==n){for(var t=r.target;t!==n;)t=t.parentNode;if(!t)return}return r.stopPropagation(),r.preventDefault(),e&&e(),n instanceof window.Element&&n.classList.remove("drag"),!1}}function f(n,e,r){return function(t){t.stopPropagation(),t.preventDefault(),r&&r(),n instanceof window.Element&&n.classList.remove("drag");var o={x:t.clientX,y:t.clientY};if(t.dataTransfer.items){var i=c(t.dataTransfer.items).filter(function(n){return"file"===n.kind});if(0===i.length)return;l(i.map(function(n){return function(e){u(n.webkitGetAsEntry(),e)}}),function(n,r){if(n)throw n;e(s(r),o)})}else{var a=c(t.dataTransfer.files);if(0===a.length)return;a.forEach(function(n){n.fullPath="/"+n.name}),e(a,o)}return!1}}function u(n,e){function r(){i.readEntries(function(n){n.length>0?(o=o.concat(c(n)),r()):t()})}function t(){l(o.map(function(n){return function(e){u(n,e)}}),e)}var o=[];if(n.isFile)n.file(function(r){r.fullPath=n.fullPath,e(null,r)},function(n){e(n)});else if(n.isDirectory){var i=n.createReader();r()}}function c(n){return Array.prototype.slice.call(n||[],0)}e.exports=t;var s=n("flatten"),l=n("run-parallel")},{flatten:2,"run-parallel":3}]},{},[])("/")});

@@ -6,8 +6,9 @@ module.exports = dragDrop

function dragDrop (elem, ondrop) {
function dragDrop (elem, listeners) {
if (typeof elem === 'string') elem = window.document.querySelector(elem)
if (typeof listeners === 'function') listeners = { onDrop: listeners }
var onDragOver = makeOnDragOver(elem)
var onDragLeave = makeOnDragLeave(elem)
var onDrop = makeOnDrop(elem, ondrop)
var onDragOver = makeOnDragOver(elem, listeners.onDragOver)
var onDragLeave = makeOnDragLeave(elem, listeners.onDragLeave)
var onDrop = makeOnDrop(elem, listeners.onDrop, listeners.onDragLeave)

@@ -35,6 +36,7 @@ elem.addEventListener('dragenter', stopEvent, false)

function makeOnDragOver (elem) {
function makeOnDragOver (elem, ondragover) {
return function (e) {
e.stopPropagation()
e.preventDefault()
if (ondragover) ondragover()
if (elem instanceof window.Element) elem.classList.add('drag')

@@ -46,7 +48,12 @@ e.dataTransfer.dropEffect = 'copy'

function makeOnDragLeave (elem) {
function makeOnDragLeave (elem, ondragleave) {
return function (e) {
if (e.target !== elem) return
if (e.target !== elem) {
var parent = e.target
while (parent !== elem) parent = parent.parentNode
if (!parent) return
}
e.stopPropagation()
e.preventDefault()
if (ondragleave) ondragleave()
if (elem instanceof window.Element) elem.classList.remove('drag')

@@ -57,6 +64,7 @@ return false

function makeOnDrop (elem, ondrop) {
function makeOnDrop (elem, ondrop, ondragleave) {
return function (e) {
e.stopPropagation()
e.preventDefault()
if (ondragleave) ondragleave()
if (elem instanceof window.Element) elem.classList.remove('drag')

@@ -63,0 +71,0 @@ var pos = { x: e.clientX, y: e.clientY }

{
"name": "drag-drop",
"description": "HTML5 drag & drop for humans",
"version": "2.6.0",
"version": "2.7.0",
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)",

@@ -6,0 +6,0 @@ "bugs": {

@@ -120,2 +120,20 @@ # drag-drop [![travis](https://img.shields.io/travis/feross/drag-drop/master.svg)](https://travis-ci.org/feross/drag-drop) [![npm](https://img.shields.io/npm/v/drag-drop.svg)](https://npmjs.org/package/drag-drop) [![downloads](https://img.shields.io/npm/dm/drag-drop.svg)](https://npmjs.org/package/drag-drop)

### detect `dragover` and `dragleave` events
Instead of passing just an `ondrop` function as the second argument, instead pass an
object with all the events you want to listen for:
```js
var dragDrop = require('drag-drop')
dragDrop('#dropTarget', {
onDrop: function (files, pos) {
console.log('Here are the dropped files', files)
console.log('Dropped at coordinates', pos.x, pos.y)
},
onDragOver: function () {},
onDragLeave: function () {}
})
```
### a note about `file://` urls

@@ -122,0 +140,0 @@

Sorry, the diff of this file is not supported yet

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