From a8fba054d071f5e4d4fbc339aa50063de617afa0 Mon Sep 17 00:00:00 2001 From: yurevich1 Date: Mon, 24 Jul 2017 10:23:36 +0300 Subject: [PATCH 1/3] final-scroll-position-type --- Source/Core/Core.swift | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Core.swift b/Source/Core/Core.swift index 3efadc43c..dcd974f34 100644 --- a/Source/Core/Core.swift +++ b/Source/Core/Core.swift @@ -1035,10 +1035,10 @@ extension FormViewControllerProtocol { // MARK: Helpers - func makeRowVisible(_ row: BaseRow) { + func makeRowVisible(_ row: BaseRow, _ isScrollToTop:Bool){ guard let cell = row.baseCell, let indexPath = row.indexPath, let tableView = tableView else { return } if cell.window == nil || (tableView.contentOffset.y + tableView.frame.size.height <= cell.frame.origin.y + cell.frame.size.height) { - tableView.scrollToRow(at: indexPath, at: .bottom, animated: true) + tableView.scrollToRow(at: indexPath, at: isScrollToTop ? .top :.bottom, animated: true) } } } From cd52a6e5140febb1c04cda292288c29a80107d47 Mon Sep 17 00:00:00 2001 From: yurevich1 Date: Mon, 24 Jul 2017 10:25:27 +0300 Subject: [PATCH 2/3] final-scroll-position-type --- Source/Core/InlineRowType.swift | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Source/Core/InlineRowType.swift b/Source/Core/InlineRowType.swift index e89eac230..aa89d1209 100644 --- a/Source/Core/InlineRowType.swift +++ b/Source/Core/InlineRowType.swift @@ -85,7 +85,8 @@ extension InlineRowType where Self: BaseRow, Self.InlineRow : BaseRow, Self.Cell if let indexPath = indexPath { _inlineRow = inline section.insert(inline, at: indexPath.row + 1) - cell.formViewController()?.makeRowVisible(inline) + let stt = isScrollToTop() + cell.formViewController()?.makeRowVisible(inline,stt) } } } From 2883e55e5d90a54f8c44b74c017889f87733d7aa Mon Sep 17 00:00:00 2001 From: yurevich1 Date: Mon, 24 Jul 2017 10:28:12 +0300 Subject: [PATCH 3/3] final-scroll-position-type --- Source/Core/BaseRow.swift | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Source/Core/BaseRow.swift b/Source/Core/BaseRow.swift index 747a805df..500cde02e 100644 --- a/Source/Core/BaseRow.swift +++ b/Source/Core/BaseRow.swift @@ -104,6 +104,21 @@ open class BaseRow: BaseRowType { self.tag = tag } + + /** + Scrolls to a wanted part of the view + Usage : + override this method somewhere in new class. + + //isScrollToTop + open override func isScrollToTop() -> Bool { + return true + } + */ + open func isScrollToTop() -> Bool { + return false + } + /** Method that reloads the cell */