-
-
Notifications
You must be signed in to change notification settings - Fork 362
Double Page (No Cover) now keep opposite flow of Double Page fixing Split Double Spreads #1236
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
d32eec5
172404a
9c38bdf
e908e05
c0559c9
50e5eac
9ea3725
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,40 +9,36 @@ export function buildSpreads(pages: PageDtoWithUrl[], pageLayout: PagedReaderLay | |
| if (pageLayout !== PagedReaderLayout.SINGLE_PAGE) { | ||
| const spreads = [] as PageDtoWithUrl[][] | ||
| const pagesClone = cloneDeep(pages) | ||
| let lastPages = undefined | ||
| if (pageLayout === PagedReaderLayout.DOUBLE_PAGES) { | ||
| const firstPage = pagesClone.shift() as PageDtoWithUrl | ||
| if (isPageLandscape(firstPage)) | ||
| spreads.push([firstPage] as PageDtoWithUrl[]) | ||
| else | ||
| spreads.push([createEmptyPage(firstPage), firstPage] as PageDtoWithUrl[]) | ||
| if (pagesClone.length > 0) { | ||
| const lastPage = pagesClone.pop() as PageDtoWithUrl | ||
| if(isPageLandscape(lastPage)) | ||
| lastPages = [lastPage] as PageDtoWithUrl[] | ||
| else | ||
| lastPages = [lastPage, createEmptyPage(lastPage)] as PageDtoWithUrl[] | ||
| } | ||
| } | ||
| while (pagesClone.length > 0) { | ||
| const p = pagesClone.shift() as PageDtoWithUrl | ||
| if (isPageLandscape(p)) { | ||
| spreads.push([p]) | ||
| } else { | ||
| if (pagesClone.length > 0) { | ||
| const p2 = pagesClone.shift() as PageDtoWithUrl | ||
| if (isPageLandscape(p2)) { | ||
| spreads.push([p, createEmptyPage(p)]) | ||
| spreads.push([p2]) | ||
| const [prevPage] = spreads.length > 0 ? (spreads[spreads.length - 1] as PageDtoWithUrl[]) : [] | ||
| if (pageLayout === PagedReaderLayout.DOUBLE_NO_COVER && isPageLandscape(prevPage)){ | ||
| spreads.push([createEmptyPage(p), p]) | ||
| } else { | ||
| spreads.push([p, p2]) | ||
| const p2 = pagesClone.shift() as PageDtoWithUrl | ||
| if (isPageLandscape(p2)) { | ||
| spreads.push([p, createEmptyPage(p)]) | ||
| spreads.push([p2]) | ||
| } else { | ||
| spreads.push([p, p2]) | ||
| } | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Basically all the same logic, just if it's DBNC layout, then just push a empty page after the previous page if and only if it was a landscape page. This guarantees the layouts will be opposite if landscape pages existed, which is what throws off the flow. |
||
| } | ||
| } else { | ||
| spreads.push([p, createEmptyPage(p)]) | ||
| } | ||
| } | ||
| } | ||
| if (lastPages) spreads.push(lastPages) | ||
| return spreads | ||
| } else { | ||
| return pages.map(p => [p]) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -95,23 +95,20 @@ describe('Double Pages', () => { | |
| ] as PageDtoWithUrl[] | ||
|
|
||
| const spreads = buildSpreads(pages, pageLayout) | ||
|
|
||
| expect(spreads.length).toEqual(4) | ||
| // Expecting [E, 1], [2, 3], [4, 5] | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Talked about this in more details with an example in the PR original post |
||
| expect(spreads.length).toEqual(3) | ||
|
|
||
| expect(spreads[0].length).toEqual(2) | ||
| expect(spreads[0][1].number).toEqual(1) | ||
| expect(spreads[0][0].number).toEqual(0) // empty page | ||
| expect(spreads[0][1].number).toEqual(1) | ||
|
|
||
| expect(spreads[1].length).toEqual(2) | ||
| expect(spreads[1][0].number).toEqual(2) | ||
| expect(spreads[1][1].number).toEqual(3) | ||
|
|
||
| expect(spreads[2].length).toEqual(2) | ||
| expect(spreads[2][0].number).toEqual(4) | ||
|
|
||
| expect(spreads[3].length).toEqual(2) | ||
| expect(spreads[3][0].number).toEqual(5) | ||
| expect(spreads[3][1].number).toEqual(0) // empty page | ||
| expect(spreads[2][1].number).toEqual(5) | ||
| }) | ||
| }) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed lastPages, and the chunk handling it below as the loop part of the algorithm handles getting the last image in place