forked from clauderic/react-sortable-hoc
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Leonardo
committed
Jan 16, 2017
1 parent
26143ea
commit 90b862a
Showing
19 changed files
with
10,467 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
*.DS_Store | ||
node_modules | ||
dist | ||
styles.min.css | ||
styles.min.css.map | ||
coverage | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
'use strict'; | ||
|
||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
|
||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
|
||
var _find = require('lodash/find'); | ||
|
||
var _find2 = _interopRequireDefault(_find); | ||
|
||
var _sortBy = require('lodash/sortBy'); | ||
|
||
var _sortBy2 = _interopRequireDefault(_sortBy); | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
|
||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
|
||
var Manager = function () { | ||
function Manager() { | ||
_classCallCheck(this, Manager); | ||
|
||
this.refs = {}; | ||
} | ||
|
||
_createClass(Manager, [{ | ||
key: 'add', | ||
value: function add(collection, ref) { | ||
if (!this.refs[collection]) this.refs[collection] = []; | ||
|
||
this.refs[collection].push(ref); | ||
} | ||
}, { | ||
key: 'remove', | ||
value: function remove(collection, ref) { | ||
var index = this.getIndex(collection, ref); | ||
|
||
if (index !== -1) { | ||
this.refs[collection].splice(index, 1); | ||
} | ||
} | ||
}, { | ||
key: 'getActive', | ||
value: function getActive() { | ||
var _this = this; | ||
|
||
return (0, _find2.default)(this.refs[this.active.collection], function (_ref) { | ||
var node = _ref.node; | ||
return node.sortableInfo.index == _this.active.index; | ||
}); | ||
} | ||
}, { | ||
key: 'getIndex', | ||
value: function getIndex(collection, ref) { | ||
return this.refs[collection].indexOf(ref); | ||
} | ||
}, { | ||
key: 'getOrderedRefs', | ||
value: function getOrderedRefs() { | ||
var collection = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : this.active.collection; | ||
|
||
return (0, _sortBy2.default)(this.refs[collection], function (_ref2) { | ||
var node = _ref2.node; | ||
return node.sortableInfo.index; | ||
}); | ||
} | ||
}]); | ||
|
||
return Manager; | ||
}(); | ||
|
||
exports.default = Manager; |
Oops, something went wrong.