Skip to content

Commit c1fae9d

Browse files
authored
Merge pull request #30 from Sparkomatic/master
Adding destroyCard() function to swing-card-component
2 parents 7acad84 + 6ea4957 commit c1fae9d

File tree

3 files changed

+15
-1
lines changed

3 files changed

+15
-1
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
},
2121
"homepage": "https://github.com/ksachdeva/angular2-swing#readme",
2222
"dependencies": {
23-
"swing": "^4.3.0"
23+
"swing": "^3.1.1"
2424
},
2525
"devDependencies": {
2626
"@angular/common": "^4.0.0",

src/swing-card-component.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import {Card} from './swing';
1111
export class SwingCardComponent {
1212
@Input() prepend: boolean = false;
1313

14+
card: Card;
15+
1416
constructor(
1517
private elmentRef: ElementRef,
1618
private swingStack: SwingStackComponent) {
@@ -31,4 +33,10 @@ export class SwingCardComponent {
3133
getCard(): Card {
3234
return this.swingStack.stack.getCard(this.getNativeElement());
3335
}
36+
37+
destroyCard() {
38+
this.swingStack.cards = this.swingStack.cards.filter(swingCardComponent => swingCardComponent !== this);
39+
let card = this.swingStack.stack.getCard(this.getNativeElement());
40+
this.swingStack.stack.destroyCard(card);
41+
}
3442
}

src/swing.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ export interface Stack {
9393
*/
9494
getCard(element: HTMLElement): Card;
9595

96+
/**
97+
*
98+
*@param {Card} card
99+
*/
100+
destroyCard(card: Card): void;
101+
96102
on(eventName: ThrowEventName, callabck: (event: ThrowEvent) => void): void;
97103
on(eventName: DragEventName, callabck: (event: DragEvent) => void): void;
98104
}

0 commit comments

Comments
 (0)