How to change throwOutDistance and trigger the throwout event from an angular app?
Awesome directory - very useful - thanks!!!
I have two questions:
- I need a smaller throwOutDistance, what is the best way to change it?
- I also need to be able to connect 2 (yes/no)-buttons to the throwout event, how can I do this in an angular app?
+1
I did hack the original angular-swing.js file:
Card.throwOutConfidence = function (offset, elementWidth) {
return Math.min(Math.abs(offset) / (elementWidth/1.5), 1);
};
Card.isThrowOut = function (offset, elementWidth) {
return Card.throwOutConfidence(offset, (elementWidth/1.5)) == 1;
};
You can also play with these two config values:
config.minThrowOutDistance = config.minThrowOutDistance ? config.minThrowOutDistance : 400;
config.maxThrowOutDistance = config.maxThrowOutDistance ? config.maxThrowOutDistance : 500;
As for the buttons, I'm sure there's another hack for them, if I have the time I'll get back here for more, I'd love to contribute and make this angular friendly but this is just for the sack of making it just work.
I guess as I understand from your question, you'd like more of yes/no but destroy the card anyway, the way of doing this is straight forward by having this code:
$scope.btnYes = function (index) {
// make some magic that will tell that the user has chosen YES!
// remove the card from stack
$scope.cards.splice(index, 1);
}
$scope.btnNo = function (index) {
// make some magic that will tell that the user has chosen NO!
// remove the card from stack
$scope.cards.splice(index, 1);
}
* I did not test the code yet, but it should work
I actually first tried changing the config values the other day but that didn´t work as expected, changing Card.throwOutConfidence and Card.isThrowOut as you suggested did the trick and solved my question 1, many thanks!
How do you implement the config using the angular version?
I second this, I'd like to know as well.