diff --git a/package.json b/package.json index 82d0f19..5251771 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/swing-card-component.ts b/src/swing-card-component.ts index c247d29..f00e392 100644 --- a/src/swing-card-component.ts +++ b/src/swing-card-component.ts @@ -11,6 +11,8 @@ import {Card} from './swing'; export class SwingCardComponent { @Input() prepend: boolean = false; + card: Card; + constructor( private elmentRef: ElementRef, private swingStack: SwingStackComponent) { @@ -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); + } } diff --git a/src/swing.ts b/src/swing.ts index 061a7a2..e0514ff 100644 --- a/src/swing.ts +++ b/src/swing.ts @@ -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; }