Skip to content

Commit f09c970

Browse files
committed
move svDisabled to be on svRoot, not per element
also fixes subtle bug
1 parent a7c5b4f commit f09c970

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

src/angular-sortable-view.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
}
2323

2424
var sortingInProgress;
25+
var isDisabled = false;
26+
2527
var ROOTS_MAP = Object.create(null);
2628
// window.ROOTS_MAP = ROOTS_MAP; // for debug purposes
2729

@@ -56,6 +58,16 @@
5658
return sortingInProgress;
5759
};
5860

61+
if ($attrs.svDisabled) {
62+
$scope.$watch($attrs.svDisabled, function(disabled) {
63+
isDisabled = disabled === true;
64+
});
65+
}
66+
67+
this.isDisabled = function() {
68+
return isDisabled;
69+
};
70+
5971
if($attrs.svGrid){ // sv-grid determined explicite
6072
isGrid = $attrs.svGrid === "true" ? true : $attrs.svGrid === "false" ? false : null;
6173
if(isGrid === null)
@@ -361,12 +373,7 @@
361373
handle.off('mousedown touchstart', onMousedown);
362374
});
363375

364-
$attrs.$observe('svDisabled', function(disabled) {
365-
disabled = $scope.$eval(disabled);
366-
if (!disabled) handle.on('mousedown touchstart', onMousedown);
367-
else handle.off('mousedown touchstart', onMousedown);
368-
});
369-
376+
handle.on('mousedown touchstart', onMousedown);
370377
$scope.$watch('$ctrl.handle', function(customHandle){
371378
if(customHandle){
372379
handle.off('mousedown touchstart', onMousedown);
@@ -397,7 +404,7 @@
397404
function onMousedown(e){
398405
touchFix(e);
399406

400-
if($controllers[1].sortingInProgress()) return;
407+
if($controllers[1].isDisabled() || $controllers[1].sortingInProgress()) return;
401408
if(e.button != 0 && e.type === 'mousedown') return;
402409

403410
moveExecuted = false;

0 commit comments

Comments
 (0)