mirror of
https://github.com/kiwix/kiwix-apple.git
synced 2025-09-27 05:49:25 -04:00
bug fixes in toc system
This commit is contained in:
parent
a5636e0b60
commit
f1035b07d6
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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) {
|
||||
@ -64,4 +64,4 @@ function TableOfContents () {
|
||||
}
|
||||
}
|
||||
|
||||
var tableOfContents = new TableOfContents();
|
||||
var tableOfContents = new TableOfContents();
|
||||
|
@ -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)
|
||||
|
Loading…
x
Reference in New Issue
Block a user