1
- import { ChangeDetectionStrategy , Component , ContentChildren , ContentChild , Directive , ElementRef , EventEmitter , Input , Optional , Output , QueryList , Renderer , ViewEncapsulation } from '@angular/core' ;
1
+ import { ChangeDetectionStrategy , Component , ContentChildren , ContentChild , Directive , ElementRef , EventEmitter , Input , Optional , Output , QueryList , Renderer , ViewEncapsulation , NgZone } from '@angular/core' ;
2
2
3
3
import { CSS , nativeRaf , nativeTimeout , clearNativeTimeout } from '../../util/dom' ;
4
4
import { Item } from './item' ;
@@ -40,7 +40,6 @@ export const enum ItemSideFlags {
40
40
selector : 'ion-item-options' ,
41
41
} )
42
42
export class ItemOptions {
43
-
44
43
/**
45
44
* @input {string} the side the option button should be on. Defaults to right
46
45
* If you have multiple `ion-item-options`, a side must be provided for each.
@@ -54,13 +53,6 @@ export class ItemOptions {
54
53
55
54
constructor ( private _elementRef : ElementRef , private _renderer : Renderer ) { }
56
55
57
- /**
58
- * @private
59
- */
60
- setCssStyle ( property : string , value : string ) {
61
- this . _renderer . setElementStyle ( this . _elementRef . nativeElement , property , value ) ;
62
- }
63
-
64
56
/**
65
57
* @private
66
58
*/
@@ -225,10 +217,14 @@ export class ItemSliding {
225
217
*/
226
218
@Output ( ) ionDrag : EventEmitter < ItemSliding > = new EventEmitter < ItemSliding > ( ) ;
227
219
228
- constructor ( @Optional ( ) list : List , private _renderer : Renderer , private _elementRef : ElementRef ) {
220
+ constructor (
221
+ @Optional ( ) list : List ,
222
+ private _renderer : Renderer ,
223
+ private _elementRef : ElementRef ,
224
+ private _zone : NgZone ) {
229
225
list && list . containsSlidingItem ( true ) ;
230
226
_elementRef . nativeElement . $ionComponent = this ;
231
- this . _setCssClass ( 'item-wrapper' , true ) ;
227
+ this . setElementClass ( 'item-wrapper' , true ) ;
232
228
}
233
229
234
230
@ContentChildren ( ItemOptions )
@@ -341,9 +337,9 @@ export class ItemSliding {
341
337
*/
342
338
private fireSwipeEvent ( ) {
343
339
if ( this . _state & SlidingState . SwipeRight ) {
344
- this . _rightOptions . ionSwipe . emit ( this ) ;
340
+ this . _zone . run ( ( ) => this . _rightOptions . ionSwipe . emit ( this ) ) ;
345
341
} else if ( this . _state & SlidingState . SwipeLeft ) {
346
- this . _leftOptions . ionSwipe . emit ( this ) ;
342
+ this . _zone . run ( ( ) => this . _leftOptions . ionSwipe . emit ( this ) ) ;
347
343
}
348
344
}
349
345
@@ -404,18 +400,18 @@ export class ItemSliding {
404
400
}
405
401
406
402
this . item . setElementStyle ( CSS . transform , `translate3d(${ - openAmount } px,0,0)` ) ;
407
- this . ionDrag . emit ( this ) ;
403
+ this . _zone . run ( ( ) => this . ionDrag . emit ( this ) ) ;
408
404
}
409
405
410
406
private _setState ( state : SlidingState ) {
411
407
if ( state === this . _state ) {
412
408
return ;
413
409
}
414
- this . _setCssClass ( 'active-slide' , ( state !== SlidingState . Disabled ) ) ;
415
- this . _setCssClass ( 'active-options-right' , ! ! ( state & SlidingState . Right ) ) ;
416
- this . _setCssClass ( 'active-options-left' , ! ! ( state & SlidingState . Left ) ) ;
417
- this . _setCssClass ( 'active-swipe-right' , ! ! ( state & SlidingState . SwipeRight ) ) ;
418
- this . _setCssClass ( 'active-swipe-left' , ! ! ( state & SlidingState . SwipeLeft ) ) ;
410
+ this . setElementClass ( 'active-slide' , ( state !== SlidingState . Disabled ) ) ;
411
+ this . setElementClass ( 'active-options-right' , ! ! ( state & SlidingState . Right ) ) ;
412
+ this . setElementClass ( 'active-options-left' , ! ! ( state & SlidingState . Left ) ) ;
413
+ this . setElementClass ( 'active-swipe-right' , ! ! ( state & SlidingState . SwipeRight ) ) ;
414
+ this . setElementClass ( 'active-swipe-left' , ! ! ( state & SlidingState . SwipeLeft ) ) ;
419
415
this . _state = state ;
420
416
}
421
417
@@ -461,16 +457,9 @@ export class ItemSliding {
461
457
/**
462
458
* @private
463
459
*/
464
- _setCssClass ( cssClass : string , shouldAdd : boolean ) {
460
+ setElementClass ( cssClass : string , shouldAdd : boolean ) {
465
461
this . _renderer . setElementClass ( this . _elementRef . nativeElement , cssClass , shouldAdd ) ;
466
462
}
467
-
468
- /**
469
- * @private
470
- */
471
- _setCssStyle ( property : string , value : string ) {
472
- this . _renderer . setElementStyle ( this . _elementRef . nativeElement , property , value ) ;
473
- }
474
463
}
475
464
476
465
function shouldClose ( isCloseDirection : boolean , isMovingFast : boolean , isOnCloseZone : boolean ) : boolean {
0 commit comments