File tree 2 files changed +15
-4
lines changed
Example/Source/Controllers
2 files changed +15
-4
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,8 @@ class HorizontalController {
17
17
18
18
lazy var removeCurrentPageAction : ( ( ) -> Void ) ? = { [ weak self] in
19
19
guard let strongSelf = self else { return }
20
- guard let currentPageIndex = strongSelf. slideController. content. index ( where: { strongSelf. slideController. currentModel === $0 } ) else {
20
+ guard let currentPageIndex = strongSelf. slideController. content
21
+ . index ( where: { strongSelf. slideController. currentModel === $0 } ) else {
21
22
return
22
23
}
23
24
strongSelf. slideController. removeAtIndex ( index: currentPageIndex)
@@ -26,7 +27,10 @@ class HorizontalController {
26
27
lazy var insertAction : ( ( ) -> Void ) ? = { [ weak self] in
27
28
guard let strongSelf = self else { return }
28
29
let page = SlideLifeCycleObjectBuilder < ColorPageLifeCycleObject > ( object: ColorPageLifeCycleObject ( ) )
29
- let index = strongSelf. slideController. content. count == 0 ? 0 : strongSelf. slideController. content. count - 1
30
+ guard let index = strongSelf. slideController. content
31
+ . index ( where: { strongSelf. slideController. currentModel === $0 } ) else {
32
+ return
33
+ }
30
34
strongSelf. slideController. insert ( object: page, index: index)
31
35
strongSelf. addedPagesCount += 1
32
36
Original file line number Diff line number Diff line change @@ -16,13 +16,20 @@ class VerticalController {
16
16
17
17
private lazy var removeAction : ( ( ) -> Void ) ? = { [ weak self] in
18
18
guard let strongSelf = self else { return }
19
- strongSelf. slideController. removeAtIndex ( index: 0 )
19
+ guard let index = strongSelf. slideController. content
20
+ . index ( where: { strongSelf. slideController. currentModel === $0 } ) else {
21
+ return
22
+ }
23
+ strongSelf. slideController. removeAtIndex ( index: index)
20
24
}
21
25
22
26
private lazy var insertAction : ( ( ) -> Void ) ? = { [ weak self] in
23
27
guard let strongSelf = self else { return }
24
28
let page = SlideLifeCycleObjectBuilder < ColorPageLifeCycleObject > ( )
25
- let index = strongSelf. slideController. content. count == 0 ? 0 : strongSelf. slideController. content. count - 1
29
+ guard let index = strongSelf. slideController. content
30
+ . index ( where: { strongSelf. slideController. currentModel === $0 } ) else {
31
+ return
32
+ }
26
33
strongSelf. slideController. insert ( object: page, index: index)
27
34
}
28
35
You can’t perform that action at this time.
0 commit comments