diff --git a/Sortable.js b/Sortable.js index cf0b5f047..ba2397730 100644 --- a/Sortable.js +++ b/Sortable.js @@ -655,8 +655,7 @@ clearInterval(this._loopId); clearInterval(autoScroll.pid); - - clearTimeout(this.dragStartTimer); + clearTimeout(this._dragStartTimer); // Unbind events _off(document, 'drop', this); @@ -885,7 +884,7 @@ selector = selector.split('.'); var tag = selector.shift().toUpperCase(), - re = new RegExp('\\s(' + selector.join('|') + ')\\s', 'g'); + re = new RegExp('\\s(' + selector.join('|') + ')(?=\\s)', 'g'); do { if ( diff --git a/ng-sortable.js b/ng-sortable.js index c292791c8..4f0b8c58f 100644 --- a/ng-sortable.js +++ b/ng-sortable.js @@ -25,8 +25,9 @@ angular.module('ng-sortable', []) - .constant('version', '0.3.7') - .directive('ngSortable', ['$parse', function ($parse) { + .constant('ngSortableVersion', '0.3.7') + .constant('ngSortableConfig', {}) + .directive('ngSortable', ['$parse', 'ngSortableConfig', function ($parse, ngSortableConfig) { var removed, nextSibling; @@ -67,7 +68,7 @@ scope: { ngSortable: "=?" }, link: function (scope, $el, attrs) { var el = $el[0], - options = scope.ngSortable || {}, + options = angular.extend(scope.ngSortable || {}, ngSortableConfig), source = getSource(el), watchers = [], sortable diff --git a/react-sortable-mixin.js b/react-sortable-mixin.js index 47d1c3656..c40c15ff0 100644 --- a/react-sortable-mixin.js +++ b/react-sortable-mixin.js @@ -134,6 +134,16 @@ this._sortableInstance = Sortable.create((this.refs[options.ref] || this).getDOMNode(), copyOptions); }, + componentWillReceiveProps: function (nextProps) { + var newState = {}, + modelName = _getModelName(this), + items; + + if (items = nextProps[modelName]) { + newState[modelName] = items; + this.setState(newState); + } + }, componentWillUnmount: function () { this._sortableInstance.destroy(); diff --git a/st/app.js b/st/app.js index fe50fe9d7..164270d9a 100644 --- a/st/app.js +++ b/st/app.js @@ -148,6 +148,9 @@ // Angular example angular.module('todoApp', ['ng-sortable']) + .constant('ngSortableConfig', {onEnd: function() { + console.log('default onEnd()'); + }}) .controller('TodoController', ['$scope', function ($scope) { $scope.todos = [ {text: 'learn angular', done: true},