Skip to content

Commit 12aff90

Browse files
authored
Scroll to top when navigating to locators in scroll mode (#329)
1 parent 009cb3a commit 12aff90

File tree

6 files changed

+533
-133
lines changed

6 files changed

+533
-133
lines changed

.github/workflows/checks.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ jobs:
2828
run: |
2929
# Check that the Carthage project is up to date.
3030
make carthage-project
31-
git diff --exit-code --name-only Support/Carthage/Readium.xcodeproj
31+
git diff --exit-code Support/Carthage/Readium.xcodeproj
3232
- name: Build
3333
run: |
3434
xcodebuild build-for-testing -scheme "$scheme" -destination "platform=$platform,name=$device"
@@ -38,7 +38,7 @@ jobs:
3838
3939
lint:
4040
name: Lint
41-
runs-on: macos-11
41+
runs-on: macos-12
4242
if: ${{ !github.event.pull_request.draft }}
4343
env:
4444
scripts: ${{ 'Sources/Navigator/EPUB/Scripts' }}
@@ -61,7 +61,7 @@ jobs:
6161

6262
int-dev:
6363
name: Integration (Local)
64-
runs-on: macos-11
64+
runs-on: macos-12
6565
if: ${{ !github.event.pull_request.draft }}
6666
defaults:
6767
run:
@@ -80,7 +80,7 @@ jobs:
8080
8181
int-spm:
8282
name: Integration (Swift Package Manager)
83-
runs-on: macos-11
83+
runs-on: macos-12
8484
if: ${{ !github.event.pull_request.draft }}
8585
defaults:
8686
run:
@@ -105,7 +105,7 @@ jobs:
105105
106106
int-carthage:
107107
name: Integration (Carthage)
108-
runs-on: macos-11
108+
runs-on: macos-12
109109
if: ${{ !github.event.pull_request.draft }}
110110
defaults:
111111
run:
@@ -133,7 +133,7 @@ jobs:
133133
int-cocoapods:
134134
name: Integration (CocoaPods)
135135
if: github.event_name == 'push'
136-
runs-on: macos-11
136+
runs-on: macos-12
137137
defaults:
138138
run:
139139
working-directory: TestApp

Sources/Navigator/EPUB/Assets/Static/scripts/readium-fixed.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2512,7 +2512,7 @@ function scrollToRange(range) {
25122512
}
25132513
function scrollToRect(rect) {
25142514
if (isScrollModeEnabled()) {
2515-
document.scrollingElement.scrollTop = rect.top + window.scrollY - window.innerHeight / 2;
2515+
document.scrollingElement.scrollTop = rect.top + window.scrollY;
25162516
} else {
25172517
document.scrollingElement.scrollLeft = snapOffset(rect.left + window.scrollX);
25182518
}

Sources/Navigator/EPUB/Assets/Static/scripts/readium-reflowable.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -2512,7 +2512,7 @@ function scrollToRange(range) {
25122512
}
25132513
function scrollToRect(rect) {
25142514
if (isScrollModeEnabled()) {
2515-
document.scrollingElement.scrollTop = rect.top + window.scrollY - window.innerHeight / 2;
2515+
document.scrollingElement.scrollTop = rect.top + window.scrollY;
25162516
} else {
25172517
document.scrollingElement.scrollLeft = snapOffset(rect.left + window.scrollX);
25182518
}

Sources/Navigator/EPUB/Scripts/src/utils.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,7 @@ function scrollToRange(range) {
188188

189189
function scrollToRect(rect) {
190190
if (isScrollModeEnabled()) {
191-
document.scrollingElement.scrollTop =
192-
rect.top + window.scrollY - window.innerHeight / 2;
191+
document.scrollingElement.scrollTop = rect.top + window.scrollY;
193192
} else {
194193
document.scrollingElement.scrollLeft = snapOffset(
195194
rect.left + window.scrollX

0 commit comments

Comments
 (0)