Skip to content

Commit

Permalink
fix(item): sliding item is closed when tapped
Browse files Browse the repository at this point in the history
closes #7094
  • Loading branch information
manucorporat committed Jun 29, 2016
1 parent 4fff262 commit 7aa559a
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
10 changes: 7 additions & 3 deletions src/components/item/item-sliding-gesture.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export class ItemSlidingGesture extends DragGesture {
}

onTapCallback(ev: any) {
if (isFromOptionButtons(ev.target)) {
if (isFromOptionButtons(ev)) {
return;
}
let didClose = this.closeOpened();
Expand Down Expand Up @@ -117,6 +117,10 @@ function getContainer(ev: any): ItemSliding {
return null;
}

function isFromOptionButtons(ele: HTMLElement): boolean {
return !!closest(ele, 'ion-item-options', true);
function isFromOptionButtons(ev: any): boolean {
let button = closest(ev.target, '.button', true);
if (!button) {
return false;
}
return !!closest(button, 'ion-item-options', true);
}
8 changes: 4 additions & 4 deletions src/components/item/item-sliding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export class ItemSliding {

/**
* @private
*/
*/
getSlidingPercent(): number {
let openAmount = this._openAmount;
if (openAmount > 0) {
Expand Down Expand Up @@ -364,7 +364,7 @@ export class ItemSliding {
this._timer = null;
}
this._openAmount = openAmount;

if (isFinal) {
this.item.setCssStyle(CSS.transition, '');

Expand All @@ -380,7 +380,7 @@ export class ItemSliding {
let state = (openAmount <= (-this._optsWidthLeftSide - SWIPE_MARGIN))
? SlidingState.Left | SlidingState.SwipeLeft
: SlidingState.Left;

this._setState(state);
}
}
Expand All @@ -392,7 +392,7 @@ export class ItemSliding {
this.item.setCssStyle(CSS.transform, '');
return;
}

this.item.setCssStyle(CSS.transform, `translate3d(${-openAmount}px,0,0)`);
this.ionDrag.emit(this);
}
Expand Down
4 changes: 2 additions & 2 deletions src/components/item/test/sliding/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ <h2>HubStruck Notifications</h2>
</button>
</ion-item-options>
<ion-item-options side="right">
<button danger (click)="share(item100)">
<button danger (click)="unread(item100)">
<ion-icon name="trash"></ion-icon>
</button>
<button (click)="favorite(item100)" >
<button (click)="unread(item100)" >
<ion-icon name="star"></ion-icon>
</button>
</ion-item-options>
Expand Down

0 comments on commit 7aa559a

Please sign in to comment.