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.0.1 to 2.1.0

2

dragdrop.bundle.js

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

!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.DragDrop=t()}}(function(){return function t(e,n,r){function o(a,u){if(!n[a]){if(!e[a]){var f="function"==typeof require&&require;if(!u&&f)return f(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return o(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(t,e){function n(t,e,n){var u=!0,f=!0;if("function"!=typeof t)throw new TypeError(i);return n===!1?u=!1:r(n)&&(u="leading"in n?!!n.leading:u,f="trailing"in n?!!n.trailing:f),a.leading=u,a.maxWait=+e,a.trailing=f,o(t,e,a)}function r(t){var e=typeof t;return"function"==e||t&&"object"==e||!1}var o=t("lodash.debounce"),i="Expected a function",a={leading:!1,maxWait:0,trailing:!1};e.exports=n},{"lodash.debounce":2}],2:[function(t,e){function n(t,e,n){function o(){m&&clearTimeout(m),s&&clearTimeout(s),s=m=y=void 0}function u(){var n=e-(f()-g);if(0>=n||n>e){s&&clearTimeout(s);var r=y;s=m=y=void 0,r&&(x=f(),d=t.apply(v,p),m||s||(p=v=null))}else m=setTimeout(u,n)}function c(){m&&clearTimeout(m),s=m=y=void 0,(h||T!==e)&&(x=f(),d=t.apply(v,p),m||s||(p=v=null))}function l(){if(p=arguments,g=f(),v=this,y=h&&(m||!b),T===!1)var n=b&&!m;else{s||b||(x=g);var r=T-(g-x),o=0>=r||r>T;o?(s&&(s=clearTimeout(s)),x=g,d=t.apply(v,p)):s||(s=setTimeout(c,r))}return o&&m?m=clearTimeout(m):m||e===T||(m=setTimeout(u,e)),n&&(o=!0,d=t.apply(v,p)),!o||m||s||(p=v=null),d}var p,s,d,g,v,m,y,x=0,T=!1,h=!0;if("function"!=typeof t)throw new TypeError(i);if(e=0>e?0:+e||0,n===!0){var b=!0;h=!1}else r(n)&&(b=n.leading,T="maxWait"in n&&a(+n.maxWait||0,e),h="trailing"in n?n.trailing:h);return l.cancel=o,l}function r(t){var e=typeof t;return"function"==e||t&&"object"==e||!1}var o=t("lodash.isnative"),i="Expected a function",a=Math.max,u=o(u=Date.now)&&u,f=u||function(){return(new Date).getTime()};e.exports=n},{"lodash.isnative":3}],3:[function(t,e){function n(t){return"string"==typeof t?t:null==t?"":t+""}function r(t){return t&&"object"==typeof t||!1}function o(t){return null==t?!1:s.call(t)==a?d.test(p.call(t)):r(t)&&u.test(t)||!1}function i(t){return t=n(t),t&&c.test(t)?t.replace(f,"\\$&"):t}var a="[object Function]",u=/^\[object .+?Constructor\]$/,f=/[.*+?^${}()|[\]\/\\]/g,c=RegExp(f.source),l=Object.prototype,p=Function.prototype.toString,s=l.toString,d=RegExp("^"+i(s).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");e.exports=o},{}],"/":[function(t,e){function n(t,e){"string"==typeof t&&(t=document.querySelector(t)),t.addEventListener("dragenter",r,!1),t.addEventListener("dragover",o(t),!1),t.addEventListener("drop",i.bind(void 0,t,e),!1)}function r(t){return t.stopPropagation(),t.preventDefault(),!1}function o(t){var e=a(function(){t.classList.add("drag"),t.timeout&&clearTimeout(t.timeout),t.timeout=setTimeout(function(){t.classList.remove("drag")},150)},100,{trailing:!1});return function(t){t.stopPropagation(),t.preventDefault(),t.dataTransfer.dropEffect="copy",e()}}function i(t,e,n){return n.stopPropagation(),n.preventDefault(),t.classList.remove("drag"),e(Array.prototype.slice.call(n.dataTransfer.files),{x:n.clientX,y:n.clientY}),!1}e.exports=n;var a=t("lodash.throttle")},{"lodash.throttle":1}]},{},[])("/")});
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.DragDrop=e()}}(function(){return function e(t,n,r){function o(a,u){if(!n[a]){if(!t[a]){var f="function"==typeof require&&require;if(!u&&f)return f(a,!0);if(i)return i(a,!0);var c=new Error("Cannot find module '"+a+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[a]={exports:{}};t[a][0].call(l.exports,function(e){var n=t[a][1][e];return o(n?n:e)},l,l.exports,e,t,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;a<r.length;a++)o(r[a]);return o}({1:[function(e,t,n){function r(e,t,n){var r=!0,f=!0;if("function"!=typeof e)throw new TypeError(a);return n===!1?r=!1:o(n)&&(r="leading"in n?!!n.leading:r,f="trailing"in n?!!n.trailing:f),u.leading=r,u.maxWait=+t,u.trailing=f,i(e,t,u)}function o(e){var t=typeof e;return"function"==t||!!e&&"object"==t}var i=e("lodash.debounce"),a="Expected a function",u={leading:!1,maxWait:0,trailing:!1};t.exports=r},{"lodash.debounce":2}],2:[function(e,t,n){function r(e,t,n){function r(){m&&clearTimeout(m),p&&clearTimeout(p),p=m=y=void 0}function i(){var n=t-(c()-v);if(0>=n||n>t){p&&clearTimeout(p);var r=y;p=m=y=void 0,r&&(x=c(),d=e.apply(g,s),m||p||(s=g=null))}else m=setTimeout(i,n)}function f(){m&&clearTimeout(m),p=m=y=void 0,(h||T!==t)&&(x=c(),d=e.apply(g,s),m||p||(s=g=null))}function l(){if(s=arguments,v=c(),g=this,y=h&&(m||!E),T===!1)var n=E&&!m;else{p||E||(x=v);var r=T-(v-x),o=0>=r||r>T;o?(p&&(p=clearTimeout(p)),x=v,d=e.apply(g,s)):p||(p=setTimeout(f,r))}return o&&m?m=clearTimeout(m):m||t===T||(m=setTimeout(i,t)),n&&(o=!0,d=e.apply(g,s)),!o||m||p||(s=g=null),d}var s,p,d,v,g,m,y,x=0,T=!1,h=!0;if("function"!=typeof e)throw new TypeError(a);if(t=0>t?0:+t||0,n===!0){var E=!0;h=!1}else o(n)&&(E=n.leading,T="maxWait"in n&&u(+n.maxWait||0,t),h="trailing"in n?n.trailing:h);return l.cancel=r,l}function o(e){var t=typeof e;return"function"==t||!!e&&"object"==t}var i=e("lodash.isnative"),a="Expected a function",u=Math.max,f=i(f=Date.now)&&f,c=f||function(){return(new Date).getTime()};t.exports=r},{"lodash.isnative":3}],3:[function(e,t,n){function r(e){return"string"==typeof e?e:null==e?"":e+""}function o(e){return!!e&&"object"==typeof e}function i(e){return null==e?!1:d.call(e)==u?v.test(p.call(e)):o(e)&&f.test(e)}function a(e){return e=r(e),e&&l.test(e)?e.replace(c,"\\$&"):e}var u="[object Function]",f=/^\[object .+?Constructor\]$/,c=/[.*+?^${}()|[\]\/\\]/g,l=RegExp(c.source),s=Object.prototype,p=Function.prototype.toString,d=s.toString,v=RegExp("^"+a(d).replace(/toString|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");t.exports=i},{}],"/":[function(e,t,n){function r(e,t){"string"==typeof e&&(e=document.querySelector(e));var n=i(e),r=a(e,t);return e.addEventListener("dragenter",o,!1),e.addEventListener("dragover",n,!1),e.addEventListener("drop",r,!1),function(){e.classList.remove("drag"),e.removeEventListener("dragenter",o,!1),e.removeEventListener("dragover",n,!1),e.removeEventListener("drop",r,!1)}}function o(e){return e.stopPropagation(),e.preventDefault(),!1}function i(e){var t=u(function(){e.classList.add("drag"),e.timeout&&clearTimeout(e.timeout),e.timeout=setTimeout(function(){e.classList.remove("drag")},150)},100,{trailing:!1});return function(e){e.stopPropagation(),e.preventDefault(),e.dataTransfer.dropEffect="copy",t()}}function a(e,t){return function(n){return n.stopPropagation(),n.preventDefault(),e.classList.remove("drag"),t(Array.prototype.slice.call(n.dataTransfer.files),{x:n.clientX,y:n.clientY}),!1}}t.exports=r;var u=e("lodash.throttle")},{"lodash.throttle":1}]},{},[])("/")});

@@ -1,13 +0,25 @@

module.exports = DragDrop
module.exports = dragDrop
var throttle = require('lodash.throttle')
function DragDrop (elem, cb) {
function dragDrop (elem, cb) {
if (typeof elem === 'string') elem = document.querySelector(elem)
elem.addEventListener('dragenter', killEvent, false)
elem.addEventListener('dragover', makeOnDragOver(elem), false)
elem.addEventListener('drop', onDrop.bind(undefined, elem, cb), false)
var onDragOver = makeOnDragOver(elem)
var onDrop = makeOnDrop(elem, cb)
elem.addEventListener('dragenter', stopEvent, false)
elem.addEventListener('dragover', onDragOver, false)
elem.addEventListener('drop', onDrop, false)
// Function to remove drag-drop listeners
return function remove () {
elem.classList.remove('drag')
elem.removeEventListener('dragenter', stopEvent, false)
elem.removeEventListener('dragover', onDragOver, false)
elem.removeEventListener('drop', onDrop, false)
}
}
function killEvent (e) {
function stopEvent (e) {
e.stopPropagation()

@@ -36,8 +48,10 @@ e.preventDefault()

function onDrop (elem, cb, e) {
e.stopPropagation()
e.preventDefault()
elem.classList.remove('drag')
cb(Array.prototype.slice.call(e.dataTransfer.files), { x: e.clientX, y: e.clientY })
return false
function makeOnDrop (elem, cb) {
return function (e) {
e.stopPropagation()
e.preventDefault()
elem.classList.remove('drag')
cb(Array.prototype.slice.call(e.dataTransfer.files), { x: e.clientX, y: e.clientY })
return false
}
}
{
"name": "drag-drop",
"description": "HTML5 drag & drop for humans",
"version": "2.0.1",
"version": "2.1.0",
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)",

@@ -16,3 +16,4 @@ "bugs": {

"browserify": "^9.0.3",
"tape": "^3.0.0",
"standard": "^3.7.1",
"tape": "^4.0.0",
"uglify-js": "^2.4.15"

@@ -39,15 +40,8 @@ },

"scripts": {
"test": "tape test/*.js",
"test": "standard && tape test/*.js",
"build": "browserify -s DragDrop -r ./ | uglifyjs -c warnings=false -m > dragdrop.bundle.js"
},
"testling": {
"files": "test/*.js",
"browsers": [
"ie/10..latest",
"chrome/25..latest",
"firefox/20..latest",
"safari/6..latest",
"opera/15.0..latest"
]
"standard": {
"ignore": "dragdrop.bundle.js"
}
}

@@ -46,3 +46,3 @@ # drag-drop [![travis](https://img.shields.io/travis/feross/drag-drop.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) [![gittip](https://img.shields.io/gittip/feross.svg)](https://www.gittip.com/feross/)

### a more complete example
### complete example

@@ -101,3 +101,19 @@ ```js

}
```
### remove listeners
To stop listening for drag & drop events and remove the event listeners, just use the
`remove` function returned by the `dragDrop` function.
```js
var dragDrop = require('drag-drop')
var remove = dragDrop('#dropTarget', function (files, pos) {
console.log('Here are the dropped files', files)
console.log('Dropped at coordinates', pos.x, pos.y)
})
// ... at some point in the future, stop listening for drag & drop events
remove()
```

@@ -104,0 +120,0 @@

@@ -8,5 +8,5 @@ var test = require('tape')

t.doesNotThrow(function () {
var dragDrop = require('../')
require('../')
})
t.end()
})

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