From f3eca12f6db171cbcfbaedec656e1b80911e74b1 Mon Sep 17 00:00:00 2001 From: Max Lynch Date: Thu, 8 Oct 2015 09:18:00 -0500 Subject: [PATCH] fix(item): sliding item updates --- ionic/components/item/item-sliding.ts | 16 +++++++++++----- ionic/components/item/test/sliding/index.ts | 8 +++++++- ionic/components/item/test/sliding/main.html | 10 ++++++++++ 3 files changed, 28 insertions(+), 6 deletions(-) diff --git a/ionic/components/item/item-sliding.ts b/ionic/components/item/item-sliding.ts index 1884f4caf5..26899832d1 100644 --- a/ionic/components/item/item-sliding.ts +++ b/ionic/components/item/item-sliding.ts @@ -39,14 +39,13 @@ import {CSS, raf} from 'ionic/util/dom'; }) @View({ template: - '' + + '' + '' + '' + ''+ '' + '' + - '' + - '', + '' directives: [NgIf] }) export class ItemSliding { @@ -76,17 +75,19 @@ export class ItemSliding { var itemSlidingContent = this.ele.querySelector('ion-item-sliding-content'); var itemOptionsContent = this.ele.querySelector('ion-item-options'); + console.log('List width', this.list.width()); + this.itemSlidingContent = itemSlidingContent; this.itemOptions = itemOptionsContent; - this.itemWidth = itemSlidingContent.offsetWidth; - this.itemOptionsWidth = itemOptionsContent && itemOptionsContent.offsetWidth || 0; + this.itemWidth = this.list.width(); this.openAmount = 0; this.gesture = new ItemSlideGesture(this, itemSlidingContent); } + close(andStopDrag) { this.openAmount = 0; @@ -163,6 +164,9 @@ class ItemSlideGesture extends DragGesture { this.el.addEventListener('touchstart', (e) => { this.item.didTouch(); + raf(() => { + this.item.itemOptionsWidth = this.item.itemOptions && this.item.itemOptions.offsetWidth || 0; + }) }) this.el.addEventListener('touchend', (e) => { @@ -176,6 +180,8 @@ class ItemSlideGesture extends DragGesture { onDragStart(ev) { if(this.item.didClose) { return; } + if(!this.item.itemOptionsWidth) { return; } + this.slide = {}; this.slide.offsetX = this.item.getOpenAmt(); diff --git a/ionic/components/item/test/sliding/index.ts b/ionic/components/item/test/sliding/index.ts index 43aed36502..c5c27ce986 100644 --- a/ionic/components/item/test/sliding/index.ts +++ b/ionic/components/item/test/sliding/index.ts @@ -4,4 +4,10 @@ import {App} from 'ionic/ionic'; @App({ templateUrl: 'main.html' }) -class E2EApp {} +class E2EApp { + constructor() { + setTimeout(() => { + this.shouldShow = true; + }, 5000); + } +} diff --git a/ionic/components/item/test/sliding/main.html b/ionic/components/item/test/sliding/main.html index 667fbebac5..be2ee91f01 100644 --- a/ionic/components/item/test/sliding/main.html +++ b/ionic/components/item/test/sliding/main.html @@ -31,4 +31,14 @@ + + +

Max Lynch

+

+ Hey do you want to go to the game tonight? +

+ + + +