Skip to content

Commit f3d3675

Browse files
committed
Apply view transition to medium cover if found
1 parent 6e21062 commit f3d3675

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

content/index.html.erb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ uuid: d45018b8-4b50-4d56-a403-aee411ab5931
44
---
55

66
<%
7-
# TODO Ideally the view-transition should be applied to these cover as well, not the case for now
87
books = recent_books
98
unless books.empty?
109
%>

content/static/view-transition.js

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,11 @@ window.addEventListener('pageswap', async (e) => {
3030
const isbn = targetBookMatch.pathname.groups.isbn
3131
setTemporaryViewTransitionNames([
3232
[document.querySelector('.profile-picture'), 'avatar'],
33-
[document.querySelector(`img[src='/cover/${isbn}-mini.jpg']`), 'cover'],
33+
[
34+
// favor medium if any, fallback to mini otherwise
35+
document.querySelector(`img[src='/cover/${isbn}-medium.jpg']`) || document.querySelector(`img[src='/cover/${isbn}-mini.jpg']`),
36+
'cover'
37+
],
3438
], e.viewTransition.finished);
3539
}
3640
}
@@ -48,7 +52,10 @@ window.addEventListener('pagereveal', async (e) => {
4852
const isbn = fromBookMatch.pathname.groups.isbn
4953
setTemporaryViewTransitionNames([
5054
[document.querySelector('.profile-picture'), 'avatar'],
51-
[document.querySelector(`img[src='/cover/${isbn}-mini.jpg']`), 'cover'],
55+
[
56+
document.querySelector(`img[src='/cover/${isbn}-medium.jpg']`) || document.querySelector(`img[src='/cover/${isbn}-mini.jpg']`),
57+
'cover'
58+
],
5259
], e.viewTransition.ready);
5360
}
5461

0 commit comments

Comments
 (0)