@alsolovyev/sorter
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -27,3 +27,3 @@ function _extends() { | ||
* | ||
* @version 1.0.1 | ||
* @version 1.0.2 | ||
* @license MIT | ||
@@ -30,0 +30,0 @@ * @author janeRivas <solovyev.a@icloud.com> |
@@ -30,3 +30,3 @@ var Sorter = (function () { | ||
* | ||
* @version 1.0.1 | ||
* @version 1.0.2 | ||
* @license MIT | ||
@@ -33,0 +33,0 @@ * @author janeRivas <solovyev.a@icloud.com> |
/*! | ||
* Sorter.js v1.0.1 | ||
* (c) 2021 janeRivas <solovyev.a@icloud.com> | ||
* Released under the MIT License. | ||
*/ | ||
* Splitter v1.0.2 | ||
* (c) 2021 janeRivas <solovyev.a@icloud.com> | ||
* Released under the MIT License. | ||
*/ | ||
var Sorter=function(){"use strict";function e(){return(e=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var i in n)Object.prototype.hasOwnProperty.call(n,i)&&(e[i]=n[i])}return e}).apply(this,arguments)}return function(){function t(e){if(!(e instanceof Element))throw TypeError("Sorter: 'container' must be an HTMLElement, not "+{}.toString.call(e));this._container=e,this._children=Array.from(this._container.children),this._isDragging=!1,this._draggedItem=null,this._draggedIndex=null,this._bind(),this._addListeners()}var n=t.prototype;return n._findChild=function(e){for(;e.parentNode!==this._container;)e=e.parentNode;return e},n._insertChild=function(e){var t=this._findIndex(e);this._draggedIndex!==t&&(this._container.insertBefore(this._draggedItem,this._draggedIndex<t?e.nextSibling:e),this._children.splice(this._draggedIndex,1),this._children.splice(t,0,this._draggedItem),this._draggedIndex=t)},n._findIndex=function(e){var t=this._children.indexOf(e);if(t<0)throw new Error("Element is not a child of the container");return t},n._toggleElementStyles=function(t,n){if(t.hasAttribute("style"))return t.removeAttribute("style");if("object"!=typeof n)throw new Error("The 'styles' expects a mapping from style properties to values");e(t.style,n)},n._onMouseDown=function(e){e.target!==this._container&&(e.preventDefault(),this._isDragging=!0,this._draggedItem=this._findChild(e.target),this._draggedIndex=this._findIndex(this._draggedItem),this._toggleElementStyles(this._draggedItem,{opacity:"0.75"}),this._toggleElementStyles(this._container,{cursor:"move"}))},n._onMouseOver=function(e){var t=e.target;this._isDragging&&t!==this._container&&this._insertChild(this._findChild(t))},n._onMouseUp=function(){this._isDragging&&(this._toggleElementStyles(this._draggedItem),this._toggleElementStyles(this._container),this._isDragging=!1,this._draggedItem=null,this._draggedIndex=null)},n._addListeners=function(){this._container.addEventListener("mousedown",this._onMouseDown),this._container.addEventListener("mouseover",this._onMouseOver),document.addEventListener("mouseup",this._onMouseUp)},n._bind=function(){this._onMouseDown=this._onMouseDown.bind(this),this._onMouseOver=this._onMouseOver.bind(this),this._onMouseUp=this._onMouseUp.bind(this)},n.destroy=function(){this._container.removeEventListener("mousedown",this._onMouseDown),this._container.removeEventListener("mouseover",this._onMouseOver),document.removeEventListener("mouseup",this._onMouseUp)},t}()}(); |
{ | ||
"name": "@alsolovyev/sorter", | ||
"description": "JavaScript library for sorting lists by drag-and-drop", | ||
"version": "1.0.1", | ||
"description": "JavaScript package for sorting lists by drag-and-drop", | ||
"version": "1.0.2", | ||
"license": "MIT", | ||
"author": "janeRivas <solovyev.a@icloud.com>", | ||
"homepage": "https://alsolovyev.github.io/sorter", | ||
"homepage": "https://alsolovyev.github.io/npm-packages/sorter", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/alsolovyev/sorter" | ||
"url": "https://github.com/alsolovyev/npm-packages", | ||
"directory": "packages/sorter" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/alsolovyev/sorter/issues" | ||
"url": "https://github.com/alsolovyev/npm-packages/issues" | ||
}, | ||
@@ -20,13 +21,6 @@ "main": "dist/sorter.esm.js", | ||
"scripts": { | ||
"build": "rollup -c" | ||
"build": "yarn lint && yarn compile", | ||
"compile": "rollup --config", | ||
"lint": "eslint src/ --ext .js" | ||
}, | ||
"devDependencies": { | ||
"@babel/core": "^7.14.0", | ||
"@babel/plugin-transform-object-assign": "^7.12.13", | ||
"@babel/preset-env": "^7.14.1", | ||
"@rollup/plugin-babel": "^5.3.0", | ||
"@rollup/plugin-eslint": "^8.0.1", | ||
"rollup": "^2.47.0", | ||
"rollup-plugin-terser": "^7.0.2" | ||
}, | ||
"files": [ | ||
@@ -39,3 +33,12 @@ "dist/*.js" | ||
"drag" | ||
] | ||
], | ||
"devDependencies": { | ||
"@babel/core": "^7.14.3", | ||
"@babel/plugin-transform-object-assign": "^7.12.13", | ||
"@babel/preset-env": "^7.14.2", | ||
"@rollup/plugin-babel": "^5.3.0", | ||
"eslint": "^7.26.0", | ||
"rollup": "^2.48.0", | ||
"rollup-plugin-terser": "^7.0.2" | ||
} | ||
} |
# 📦 Sorter | ||
JavaScript library for sorting lists by drag-and-drop.<br/> | ||
Demo: [alsolovyev.github.io/sorter](http://alsolovyev.github.io/sorter) | ||
JavaScript package for sorting lists by drag-and-drop.<br/> | ||
Demo: [alsolovyev.github.io/npm-packages/sorter](http://alsolovyev.github.io/npm-packages/sorter) | ||
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) | ||
[![Sorter](https://habrastorage.org/webt/1p/j-/1u/1pj-1uuogi98hvpj6ayfdu8_ps4.jpeg)](http://alsolovyev.github.io/sorter) | ||
[![Sorter](https://habrastorage.org/webt/1p/j-/1u/1pj-1uuogi98hvpj6ayfdu8_ps4.jpeg)](http://alsolovyev.github.io/npm-packages/sorter) | ||
@@ -9,0 +9,0 @@ <br/> |
Sorry, the diff of this file is not supported yet
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
0
16402
6
312