Skip to content

Commit

Permalink
Merge pull request #30 from Sparkomatic/master
Browse files Browse the repository at this point in the history
Adding destroyCard() function to swing-card-component
  • Loading branch information
mashhoodr authored Jul 5, 2017
2 parents 7acad84 + 6ea4957 commit c1fae9d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
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.3.0"
"swing": "^3.1.1"
},
"devDependencies": {
"@angular/common": "^4.0.0",
Expand Down
8 changes: 8 additions & 0 deletions src/swing-card-component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import {Card} from './swing';
export class SwingCardComponent {
@Input() prepend: boolean = false;

card: Card;

constructor(
private elmentRef: ElementRef,
private swingStack: SwingStackComponent) {
Expand All @@ -31,4 +33,10 @@ export class SwingCardComponent {
getCard(): Card {
return this.swingStack.stack.getCard(this.getNativeElement());
}

destroyCard() {
this.swingStack.cards = this.swingStack.cards.filter(swingCardComponent => swingCardComponent !== this);
let card = this.swingStack.stack.getCard(this.getNativeElement());
this.swingStack.stack.destroyCard(card);
}
}
6 changes: 6 additions & 0 deletions src/swing.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ export interface Stack {
*/
getCard(element: HTMLElement): Card;

/**
*
*@param {Card} card
*/
destroyCard(card: Card): void;

on(eventName: ThrowEventName, callabck: (event: ThrowEvent) => void): void;
on(eventName: DragEventName, callabck: (event: DragEvent) => void): void;
}
Expand Down

0 comments on commit c1fae9d

Please sign in to comment.