@@ -10,10 +10,10 @@ import { ItemOptions } from './item-options';
10
10
const SWIPE_MARGIN = 30 ;
11
11
const ELASTIC_FACTOR = 0.55 ;
12
12
13
- export const ITEM_SIDE_FLAG_NONE = 0 ;
14
- export const ITEM_SIDE_FLAG_LEFT = 1 << 0 ;
15
- export const ITEM_SIDE_FLAG_RIGHT = 1 << 1 ;
16
- export const ITEM_SIDE_FLAG_BOTH = ITEM_SIDE_FLAG_LEFT | ITEM_SIDE_FLAG_RIGHT ;
13
+ const ITEM_SIDE_FLAG_NONE = 0 ;
14
+ const ITEM_SIDE_FLAG_LEFT = 1 << 0 ;
15
+ const ITEM_SIDE_FLAG_RIGHT = 1 << 1 ;
16
+ const ITEM_SIDE_FLAG_BOTH = ITEM_SIDE_FLAG_LEFT | ITEM_SIDE_FLAG_RIGHT ;
17
17
18
18
19
19
const enum SlidingState {
@@ -121,6 +121,7 @@ const enum SlidingState {
121
121
encapsulation : ViewEncapsulation . None
122
122
} )
123
123
export class ItemSliding {
124
+
124
125
private _openAmount : number = 0 ;
125
126
private _startX : number = 0 ;
126
127
private _optsWidthRightSide : number = 0 ;
@@ -166,7 +167,8 @@ export class ItemSliding {
166
167
private _dom : DomController ,
167
168
private _renderer : Renderer ,
168
169
private _elementRef : ElementRef ,
169
- private _zone : NgZone ) {
170
+ private _zone : NgZone
171
+ ) {
170
172
list && list . containsSlidingItem ( true ) ;
171
173
_elementRef . nativeElement . $ionComponent = this ;
172
174
this . setElementClass ( 'item-wrapper' , true ) ;
@@ -180,13 +182,13 @@ export class ItemSliding {
180
182
this . _leftOptions = this . _rightOptions = null ;
181
183
182
184
for ( var item of itemOptions . toArray ( ) ) {
183
- var side = item . getSides ( ) ;
184
- if ( side === ITEM_SIDE_FLAG_LEFT ) {
185
- this . _leftOptions = item ;
186
- } else {
185
+ if ( item . isRightSide ( ) ) {
187
186
this . _rightOptions = item ;
187
+ sides |= ITEM_SIDE_FLAG_RIGHT ;
188
+ } else {
189
+ this . _leftOptions = item ;
190
+ sides |= ITEM_SIDE_FLAG_LEFT ;
188
191
}
189
- sides |= item . getSides ( ) ;
190
192
}
191
193
this . _optsDirty = true ;
192
194
this . _sides = sides ;
@@ -203,7 +205,7 @@ export class ItemSliding {
203
205
* @hidden
204
206
*/
205
207
getSlidingPercent ( ) : number {
206
- let openAmount = this . _openAmount ;
208
+ const openAmount = this . _openAmount ;
207
209
if ( openAmount > 0 ) {
208
210
return openAmount / this . _optsWidthRightSide ;
209
211
} else if ( openAmount < 0 ) {
@@ -272,9 +274,9 @@ export class ItemSliding {
272
274
273
275
// Check if the drag didn't clear the buttons mid-point
274
276
// and we aren't moving fast enough to swipe open
275
- let isResetDirection = ( this . _openAmount > 0 ) === ! ( velocity < 0 ) ;
276
- let isMovingFast = Math . abs ( velocity ) > 0.3 ;
277
- let isOnCloseZone = Math . abs ( this . _openAmount ) < Math . abs ( restingPoint / 2 ) ;
277
+ const isResetDirection = ( this . _openAmount > 0 ) === ! ( velocity < 0 ) ;
278
+ const isMovingFast = Math . abs ( velocity ) > 0.3 ;
279
+ const isOnCloseZone = Math . abs ( this . _openAmount ) < Math . abs ( restingPoint / 2 ) ;
278
280
if ( swipeShouldReset ( isResetDirection , isMovingFast , isOnCloseZone ) ) {
279
281
restingPoint = 0 ;
280
282
}
@@ -330,14 +332,14 @@ export class ItemSliding {
330
332
331
333
} else {
332
334
if ( openAmount > 0 ) {
333
- let state = ( openAmount >= ( this . _optsWidthRightSide + SWIPE_MARGIN ) )
335
+ var state = ( openAmount >= ( this . _optsWidthRightSide + SWIPE_MARGIN ) )
334
336
? SlidingState . Right | SlidingState . SwipeRight
335
337
: SlidingState . Right ;
336
338
337
339
this . _setState ( state ) ;
338
340
339
341
} else if ( openAmount < 0 ) {
340
- let state = ( openAmount <= ( - this . _optsWidthLeftSide - SWIPE_MARGIN ) )
342
+ var state = ( openAmount <= ( - this . _optsWidthLeftSide - SWIPE_MARGIN ) )
341
343
? SlidingState . Left | SlidingState . SwipeLeft
342
344
: SlidingState . Left ;
343
345
0 commit comments