Skip to content
This repository has been archived by the owner on Aug 12, 2022. It is now read-only.

Commit

Permalink
2.0.0-beta.2 (#165)
Browse files Browse the repository at this point in the history
  • Loading branch information
mickael-menu authored Apr 14, 2021
1 parent dfaa0b7 commit ee9d5ee
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 43 deletions.
9 changes: 4 additions & 5 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ All notable changes to this project will be documented in this file.
**Warning:** Features marked as *experimental* may change or be removed in a future release without notice. Use with
*caution.

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

## [2.0.0-beta.2]

### Added

* New `EPUBNavigatorDelegate` APIs to inject custom JavaScript.
* Override `navigator(_:setupUserScripts:)` to register additional user script to the `WKUserContentController` of each web view.
* Override `navigator(_:userContentController:didReceive:)` to receive callbacks from your scripts.

### Changed

* CocoaPods is not supported anymore.

### Fixed

* Optimized performances of preloaded EPUB resources.
Expand Down Expand Up @@ -75,3 +73,4 @@ progression. Now if no reading progression is set, the `effectiveReadingProgress
[2.0.0-alpha.1]: https://github.com/readium/r2-navigator-swift/compare/1.2.6...2.0.0-alpha.1
[2.0.0-alpha.2]: https://github.com/readium/r2-navigator-swift/compare/2.0.0-alpha.1...2.0.0-alpha.2
[2.0.0-beta.1]: https://github.com/readium/r2-navigator-swift/compare/2.0.0-alpha.2...2.0.0-beta.1
[2.0.0-beta.2]: https://github.com/readium/r2-navigator-swift/compare/2.0.0-beta.1...2.0.0-beta.2
2 changes: 1 addition & 1 deletion Cartfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
github "readium/r2-shared-swift" "develop"
github "readium/r2-shared-swift" == 2.0.0-beta.2
github "scinfu/SwiftSoup" == 2.3.2
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
github "cezheng/Fuzi" "3.1.3"
github "dexman/Minizip" "1.4.0"
github "readium/r2-shared-swift" "8065a61e72b46214a71f7128c8ce1594fc30c85d"
github "readium/r2-shared-swift" "2.0.0-beta.2"
github "scinfu/SwiftSoup" "2.3.2"
2 changes: 1 addition & 1 deletion R2Navigator.podspec
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Pod::Spec.new do |s|

s.name = "R2Navigator"
s.version = "2.0.0-beta.1"
s.version = "2.0.0-beta.2"
s.license = "BSD 3-Clause License"
s.summary = "R2 Navigator"
s.homepage = "http://readium.github.io"
Expand Down
2 changes: 1 addition & 1 deletion r2-navigator-swift.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0830;
LastUpgradeCheck = 1230;
LastUpgradeCheck = 1240;
ORGANIZATIONNAME = Readium;
TargetAttributes = {
F3E7D3C21F4D83B000DF166D = {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1230"
LastUpgradeVersion = "1240"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
40 changes: 17 additions & 23 deletions r2-navigator-swift/EPUB/EPUBReflowableSpreadView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,18 @@ final class EPUBReflowableSpreadView: EPUBSpreadView {

override func spreadDidLoad() {
// FIXME: Better solution for delaying scrolling to pending location
// This delay is used to wait for the web view pagination to settle and give the CSS and webview time to layout correctly before attempting to scroll to the target progression, otherwise we might end up at the wrong spot. 0.2 seconds seems like a good value for it to work on an iPhone 5s.
// This delay is used to wait for the web view pagination to settle and give the CSS and webview time to layout
// correctly before attempting to scroll to the target progression, otherwise we might end up at the wrong spot.
// 0.2 seconds seems like a good value for it to work on an iPhone 5s.
DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
self.go(to: self.pendingLocation) {
self.showSpread()
let location = self.pendingLocation
self.go(to: location) {
// The rendering is sometimes very slow. So in case we don't show the first page of the resource, we add
// a generous delay before showing the spread again.
let delayed = !location.isStart
DispatchQueue.main.asyncAfter(deadline: .now() + (delayed ? 0.3 : 0)) {
self.showSpread()
}
}
}
}
Expand Down Expand Up @@ -198,22 +206,13 @@ final class EPUBReflowableSpreadView: EPUBSpreadView {
return
}

// The rendering is sometimes very slow. So in case we don't show the first page of the resource, we add a
// generous delay before showing the view again.
func complete() {
let delayed = !location.isStart
DispatchQueue.main.asyncAfter(deadline: .now() + (delayed ? 0.3 : 0)) {
completion()
}
}

switch location {
case .locator(let locator):
go(to: locator, completion: complete)
go(to: locator, completion: completion)
case .start:
go(toProgression: 0, completion: complete)
go(toProgression: 0, completion: completion)
case .end:
go(toProgression: 1, completion: complete)
go(toProgression: 1, completion: completion)
}
}

Expand All @@ -223,18 +222,13 @@ final class EPUBReflowableSpreadView: EPUBSpreadView {
completion()
return
}
guard !locator.locations.isEmpty else {
completion()
return
}


// FIXME: find the first fragment matching a tag ID (need a regex)
if let id = locator.locations.fragments.first, !id.isEmpty {
go(toTagID: id, completion: completion)
} else if let progression = locator.locations.progression {
go(toProgression: progression, completion: completion)
} else {
completion()
let progression = locator.locations.progression ?? 0
go(toProgression: progression, completion: completion)
}
}

Expand Down
11 changes: 1 addition & 10 deletions r2-navigator-swift/Toolkit/PaginationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -211,19 +211,10 @@ final class PaginationView: UIView, Loggable {
}
}

var isCompleted = false
let complete = {
guard !isCompleted else { return }
isCompleted = true
loadNextPage {
completion()
self.delegate?.paginationViewDidUpdateViews(self)
}

if loadedViews[index] != nil { // Already loaded.
complete()
}

loadNextPage(completion: complete)
}

private func loadNextPage(completion: @escaping () -> Void = {}) {
Expand Down

0 comments on commit ee9d5ee

Please sign in to comment.