Created
April 22, 2015 00:20
-
-
Save mhartington/c5107ccd9204b755442b to your computer and use it in GitHub Desktop.
Dynamically allow ion-items dragging
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
angular.module('canDragDirective', [ionic]) | |
.directive('isPurchased', function($timeout, $ionicListDelegate) { | |
return { | |
restrict: 'A', | |
link: function($scope, $element) { | |
$timeout(function() { | |
var elm = $element[0]; | |
ionic.on('touch', function() { | |
// Simple way to check if the item is already purchased | |
if (elm.classList.contains('purchased')) { | |
// if it is, disable the drag | |
$ionicListDelegate.canSwipeItems(false); | |
} else { | |
// if not, allow the drag | |
$ionicListDelegate.canSwipeItems(true); | |
} | |
//console.log($ionicListDelegate.canSwipeItems()); | |
}, elm); | |
}); | |
} | |
}; | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment