From 4457820b0a5f95547cf8f9d7596beced1a183be3 Mon Sep 17 00:00:00 2001 From: Brandy Carney Date: Wed, 19 Jul 2017 11:58:03 -0400 Subject: [PATCH] fix(item): update test to call methods and fix gesture --- .../components/item-sliding/item-sliding.tsx | 10 +- .../components/item-sliding/test/basic.html | 180 ++++++++++++++---- packages/core/src/components/list/list.tsx | 12 +- 3 files changed, 158 insertions(+), 44 deletions(-) diff --git a/packages/core/src/components/item-sliding/item-sliding.tsx b/packages/core/src/components/item-sliding/item-sliding.tsx index c64dce05a7..ecfe9a198e 100644 --- a/packages/core/src/components/item-sliding/item-sliding.tsx +++ b/packages/core/src/components/item-sliding/item-sliding.tsx @@ -1,4 +1,4 @@ -import { Component, h, Ionic, State } from '@stencil/core'; +import { Component, h, Ionic, Method, State } from '@stencil/core'; import { GestureDetail, HostElement } from '../../utils/interfaces'; import { swipeShouldReset } from '../../utils/helpers'; @@ -240,7 +240,10 @@ export class ItemSliding { } onDragEnd(gesture: GestureDetail) { - this.selectedContainer.endSliding(gesture.velocityX); + let coordX = gesture.currentX; + let deltaX = (coordX - this.firstCoordX); + let deltaT = (Date.now() - this.firstTimestamp); + this.selectedContainer.endSliding(deltaX / deltaT); this.selectedContainer = null; this.preSelectedContainer = null; } @@ -461,6 +464,7 @@ export class ItemSliding { * } * ``` */ + @Method() close() { this.setOpenAmount(0, true); } @@ -498,4 +502,4 @@ export class ItemSliding { ); } -} \ No newline at end of file +} diff --git a/packages/core/src/components/item-sliding/test/basic.html b/packages/core/src/components/item-sliding/test/basic.html index a888dcaa75..1d27e86e20 100644 --- a/packages/core/src/components/item-sliding/test/basic.html +++ b/packages/core/src/components/item-sliding/test/basic.html @@ -8,15 +8,27 @@ + + + Sliding Items + + Dynamic + + + Reload + + + +
Toggle sliding - Change Dynamic Options + Toggle Dynamic Options Close Opened Items
- + @@ -33,14 +45,14 @@ One Line, dynamic option and text - + - {{ moreText }} + - {{ archiveText }} + @@ -56,19 +68,19 @@ - + - {{ moreText }} + - {{ archiveText }} + - +

HubStruck Notifications

@@ -81,12 +93,12 @@
- + No close - + @@ -97,13 +109,13 @@
- +

RIGHT side - no icons

Hey do you want to go to the game tonight?

- + Archive Delete @@ -116,7 +128,7 @@

I think I figured out how to get more Mountain Dew

- + Archive Delete @@ -130,13 +142,13 @@

I think I figured out how to get more Mountain Dew

- + Unread - + Archive @@ -153,7 +165,7 @@

I think I figured out how to get more Mountain Dew

- + Unread @@ -163,7 +175,7 @@ Archive - + Delete @@ -178,14 +190,14 @@ - + Archive
- + @@ -201,7 +213,7 @@ Archive - + Delete
@@ -217,11 +229,11 @@ - {{ moreText }} + - {{ archiveText }} + @@ -236,14 +248,16 @@

Paragraph text.

- + Archive - +
Download
- + + +
Loading...
@@ -267,7 +281,7 @@ - +

Normal button (no sliding)

Hey do you want to go to the game tonight?

@@ -277,32 +291,118 @@
+
diff --git a/packages/core/src/components/list/list.tsx b/packages/core/src/components/list/list.tsx index 5d21e3151e..507ee2ec70 100644 --- a/packages/core/src/components/list/list.tsx +++ b/packages/core/src/components/list/list.tsx @@ -1,4 +1,4 @@ -import { Component, h } from '@stencil/core'; +import { Component, h, Method } from '@stencil/core'; @Component({ tag: 'ion-list', @@ -15,4 +15,14 @@ export class List { render() { return ; } + + /** + * Close any sliding items that are open. + */ + @Method() + closeSlidingItems() { + // TODO implement this + console.log('in list method closeSlidingItems'); + // this._slidingGesture && this._slidingGesture.closeOpened(); + } }