Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions src/angular-sortable-view.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,15 @@
var $original; // original element
var $target; // last best candidate
var isGrid = false;
var isDisabled = false;
var onSort = $parse($attrs.svOnSort);


// not sure if this is efficient?
$scope.$watch($parse($attrs.svDisabled), function(newVal, oldVal) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$attrs.observe('svDisabled', ...) would be better.

isDisabled = newVal;
});

// ----- hack due to https://github.com/angular/angular.js/issues/8044
$attrs.svOnStart = $attrs.$$element[0].attributes['sv-on-start'];
$attrs.svOnStart = $attrs.svOnStart && $attrs.svOnStart.value;
Expand All @@ -56,6 +63,9 @@
return sortingInProgress;
};

this.sortingDisabled = function() {
return isDisabled;
};
if($attrs.svGrid){ // sv-grid determined explicite
isGrid = $attrs.svGrid === "true" ? true : $attrs.svGrid === "false" ? false : null;
if(isGrid === null)
Expand Down Expand Up @@ -391,6 +401,10 @@
touchFix(e);

if($controllers[1].sortingInProgress()) return;

// do nothing if sorting is disabled
if ($controllers[1].sortingDisabled()) return;

if(e.button != 0 && e.type === 'mousedown') return;

moveExecuted = false;
Expand Down