bug fixes in toc system

This commit is contained in:
Chris Li 2017-01-05 13:43:54 -05:00
parent a5636e0b60
commit f1035b07d6
3 changed files with 13 additions and 10 deletions

View File

@ -42,6 +42,7 @@ extension MainController: UIWebViewDelegate, SFSafariViewControllerDelegate {
func webViewDidFinishLoad(_ webView: UIWebView) {
JS.inject(webView: webView)
JS.preventDefaultLongTap(webView: webView)
tableOfContentsController?.headings = JS.getTableOfContents(webView: webView)
JS.startTOCCallBack(webView: webView)
URLResponseCache.shared.stop()
@ -93,10 +94,10 @@ extension MainController: SearchBarDelegate, SearchContainerDelegate {
controller.delegate = self
guard !childViewControllers.contains(controller) else {return}
navigationController?.setToolbarHidden(true, animated: animated)
// add cancel button if needed
// hide toolbar
// add cancel button
if traitCollection.horizontalSizeClass == .compact {
navigationController?.setToolbarHidden(true, animated: animated)
navigationItem.setRightBarButton(buttons.cancel, animated: animated)
}
@ -125,10 +126,10 @@ extension MainController: SearchBarDelegate, SearchContainerDelegate {
private func hideSearch(animated: Bool) {
guard let searchController = childViewControllers.flatMap({$0 as? SearchContainer}).first else {return}
navigationController?.setToolbarHidden(false, animated: animated)
// remove cancel button if needed
// show toolbar
// remove cancel button
if traitCollection.horizontalSizeClass == .compact {
navigationController?.setToolbarHidden(false, animated: animated)
navigationItem.setRightBarButton(nil, animated: animated)
}
@ -167,7 +168,6 @@ extension MainController: ButtonDelegates {
}
func didTapTOCButton() {
tableOfContentsController?.headings = JS.getTableOfContents(webView: webView)
isShowingTableOfContents ? hideTableOfContents(animated: true) : showTableOfContents(animated: true)
}

View File

@ -29,7 +29,7 @@ function TableOfContents () {
var element = this.headings[i];
var rect = element.getBoundingClientRect();
var isAboveTopBorder = rect.bottom < 0;
var isAboveTopBorder = rect.top - 10 < 0;
var isBelowBottomBorder = viewHeight - rect.top < 0;
if (isAboveTopBorder) {

View File

@ -78,10 +78,13 @@ class ArticleLoadOperation: Procedure {
OperationQueue.main.addOperation {
_ = main.searchBar.resignFirstResponder()
main.hideTableOfContents(animated: true)
main.presentingViewController?.dismiss(animated: self.animated, completion: nil)
main.hideWelcome()
if main.traitCollection.horizontalSizeClass == .compact {
main.hideTableOfContents(animated: true)
}
let webView = main.webView
if webView?.request?.url != url {
webView?.loadRequest(request)