Skip to content

Commit

Permalink
Merge pull request #3 from Sparkomatic/master
Browse files Browse the repository at this point in the history
throwOutConfidence in StackConfig interface now receives offsetX and offsetY args
  • Loading branch information
mashhoodr authored Mar 21, 2017
2 parents d557f4d + 281cbe7 commit aa951c2
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
node_modules
npm-debug.log
typings
dist
aot
.idea/
.idea/
15 changes: 9 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,16 @@ export class AppComponent {
constructor() {

this.stackConfig = {
throwOutConfidence: (offset: number, targetElement: HTMLElement) => {
// you would put ur logic based on offset & targetelement to determine
// what is your throwout confidence
return 1;
// Default setting only allows UP, LEFT and RIGHT so you can override this as below
allowedDirections: [Direction.UP, Direction.DOWN, Direction.LEFT, Direction.RIGHT],
// Now need to send offsetX and offsetY with element instead of just offset
throwOutConfidence: (offsetX, offsetY, element) => {
return Math.min(Math.max(Math.abs(offsetX) / (element.offsetWidth / 1.7), Math.abs(offsetY) / (element.offsetHeight / 2)), 1);
},
minThrowOutDistance: 700 // default value is 400
};
throwOutDistance: (d) => {
return 800;
}
}

this.cards = [
{ name: 'clubs', symbol: '' },
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
},
"homepage": "https://github.com/ksachdeva/angular2-swing#readme",
"dependencies": {
"swing": "^4.0.0"
"swing": "^4.2.0"
},
"devDependencies": {
"@angular/common": "^2.0.2",
Expand Down
5 changes: 3 additions & 2 deletions src/swing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,12 @@ export interface StackConfig {
*
* Ration of the absolute distance from the original card position and element width.
*
* @param {Number} offset Distance from the dragStart.
* @param {Number} offsetX Distance from the dragStart.
* @param {Number} offsetY Distance from the dragStart.
* @param {HTMLElement} element Element.
* @return {Number}
*/
throwOutConfidence?: (offset: number, element: HTMLElement) => number;
throwOutConfidence?: (offsetX: number, offsetY: number, element: HTMLElement) => number;

/**
* Calculates a distances at which the card is thrown out of the stack.
Expand Down

0 comments on commit aa951c2

Please sign in to comment.