Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@

All notable changes to this project will be documented in this file. Take a look at [the migration guide](docs/Migration%20Guide.md) to upgrade between two major versions.

<!-- ## [Unreleased] -->
## [Unreleased]

### Added

#### Navigator

* The EPUB navigator now calls the new `EPUBNavigatorDelegate.navigatorDidLoadSpread(_:)` delegate method when the currently visible spread finishes loading, just before its content is faded in. This lets a host app dismiss its own loading cover exactly when the visible content appears. The method has a default empty implementation, so existing conformers are unaffected.


## [3.10.0] - 2026-06-24

Expand Down
18 changes: 18 additions & 0 deletions Sources/Navigator/EPUB/EPUBNavigatorViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,22 @@ import WebKit
// MARK: - WebView Customization

func navigator(_ navigator: EPUBNavigatorViewController, setupUserScripts userContentController: WKUserContentController)

// MARK: - Loading

/// Called when the current spread has finished loading and is about to be
/// revealed: once when the publication opens, and again after each page turn.
/// Only the visible spread triggers it, not the preloaded adjacent ones.
///
Comment on lines +23 to +26
/// A host showing its own loading cover can dismiss it here without exposing
/// the navigator's loading indicator.
func navigatorDidLoadSpread(_ navigator: EPUBNavigatorViewController)
}

public extension EPUBNavigatorDelegate {
func navigator(_ navigator: EPUBNavigatorViewController, setupUserScripts userContentController: WKUserContentController) {}

func navigatorDidLoadSpread(_ navigator: EPUBNavigatorViewController) {}
}

public typealias EPUBContentInsets = (top: CGFloat, bottom: CGFloat)
Expand Down Expand Up @@ -1082,6 +1094,12 @@ extension EPUBNavigatorViewController: EPUBSpreadViewDelegate {
}

await spreadView.evaluateScript("(function() {\n\(script)\n})();")

// Only the visible spread, not the adjacent spreads preloaded around it,
// which can finish loading before this one is revealed.
if spreadView === paginationView?.currentView {
delegate?.navigatorDidLoadSpread(self)
}
}

func spreadView(_ spreadView: EPUBSpreadView, didReceive event: PointerEvent) {
Expand Down
Loading