1
1
import { Component } from '@angular/core' ;
2
- import { IonicPage , NavController , NavParams } from 'ionic-angular' ;
2
+ import { IonicPage , NavController } from 'ionic-angular' ;
3
3
import { Item , ItemSliding } from 'ionic-angular' ;
4
4
5
5
@IonicPage ( )
@@ -8,7 +8,9 @@ import { Item, ItemSliding } from 'ionic-angular';
8
8
templateUrl : 'delete-items.html' ,
9
9
} )
10
10
export class DeleteItemsPage {
11
+
11
12
activeItemSliding : ItemSliding = null ;
13
+
12
14
items = [
13
15
{
14
16
title : 'Item 1' ,
@@ -20,6 +22,7 @@ export class DeleteItemsPage {
20
22
title : 'Item 3' ,
21
23
} ,
22
24
]
25
+
23
26
things = [
24
27
{
25
28
title : 'Thing 1' ,
@@ -31,38 +34,41 @@ export class DeleteItemsPage {
31
34
title : 'Thing 3' ,
32
35
} ,
33
36
]
34
- constructor ( public navCtrl : NavController , public navParams : NavParams ) {
35
- }
36
37
37
- ionViewDidLoad ( ) {
38
- console . log ( 'ionViewDidLoad DeleteItemsPage' ) ;
39
- }
40
- addThing ( ) {
38
+ constructor ( public navCtrl : NavController ) { }
39
+
40
+ addThing ( ) {
41
41
console . log ( 'add thing' ) ;
42
- this . things . push ( { title : 'Thing ' + ( + this . things . length + 1 ) } )
42
+ this . things . push ( { title : 'Thing ' + ( this . things . length + 1 ) } )
43
43
}
44
- addItem ( ) {
44
+
45
+ addItem ( ) {
45
46
console . log ( 'add item' ) ;
46
- this . items . push ( { title : 'Item ' + ( + this . items . length + 1 ) } )
47
+ this . items . push ( { title : 'Item ' + ( this . items . length + 1 ) } )
48
+ }
49
+
50
+ deleteItem ( list , index ) {
51
+ list . splice ( index , 1 ) ;
47
52
}
53
+
48
54
openOption ( itemSlide : ItemSliding , item : Item , event ) {
49
55
console . log ( 'opening item slide..' ) ;
50
56
event . stopPropagation ( ) ; //here if you want item to be tappable
51
- if ( this . activeItemSliding !== null ) { //use this so that only one active sliding item allowed
57
+ if ( this . activeItemSliding ) { //use this so that only one active sliding item allowed
52
58
this . closeOption ( ) ;
53
59
}
60
+
54
61
this . activeItemSliding = itemSlide ;
55
- let swipeAmount = 33 ; //set your required swipe amount
56
- //to do, can we make this width calculated?
57
- console . log ( 'swipe amount ' , itemSlide ) ;
58
- // console shows itemSlide._optsWidthRightSide is calculated, but it's a private var
62
+ const swipeAmount = 33 ; //set your required swipe amount
59
63
64
+ console . log ( 'swipe amount ' , swipeAmount ) ;
60
65
itemSlide . startSliding ( swipeAmount ) ;
61
66
itemSlide . moveSliding ( swipeAmount ) ;
62
67
68
+ itemSlide . setElementClass ( 'active-slide' , true ) ;
63
69
itemSlide . setElementClass ( 'active-options-right' , true ) ;
64
70
item . setElementStyle ( 'transition' , null ) ;
65
- item . setElementStyle ( 'transform' , 'translate3d(-' + swipeAmount + 'px, 0px, 0px)' ) ;
71
+ item . setElementStyle ( 'transform' , 'translate3d(-' + swipeAmount + 'px, 0px, 0px)' ) ;
66
72
}
67
73
68
74
closeOption ( ) {
0 commit comments