Skip to content

Commit

Permalink
Refactor and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jrlarano committed Mar 20, 2024
1 parent bffab8a commit cdb5f60
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 66 deletions.
7 changes: 0 additions & 7 deletions lib/kits/core-ui/page-decorations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,12 @@ const PageDecorations = () => {
const render = ({
pageDecorations,
aspectRatio,
versoPageSpread,
versoPageSpreads,
pageSpread,
pageSpreads
}: {
pageDecorations: V2PageDecoration[];
aspectRatio: {};
versoPageSpread?: PageSpread;
versoPageSpreads?: PageSpread[];
pageSpread?: PagedPublicationPageSpread;
pageSpreads?: PagedPublicationPageSpread[];
}) => {
if (pageDecorationsContainer?.innerHTML) {
Expand Down Expand Up @@ -119,15 +115,12 @@ const PageDecorations = () => {
let top = Math.round(
((contentRect?.height || 0) / 100) * (hotspot.y1! * 100)
);

let left = Math.round(
((contentRect?.width || 0) / 100) * (x1 * 100)
);

const width = Math.round(
((contentRect?.width || 0) / 100) * ((x2 - x1) * 100)
);

const height = Math.round(
((contentRect?.height || 0) / 100) *
((hotspot.y2 - hotspot.y1) * 100)
Expand Down
3 changes: 2 additions & 1 deletion lib/kits/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@ export interface V2PageDecoration {
x2: number;
y1: number;
y2: number;
type: string;
rotate: number;
link_embed: boolean;
link: string;
}[]
| null;
Expand Down
52 changes: 0 additions & 52 deletions lib/kits/paged-publication/bootstrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,58 +117,6 @@ export default class Bootstrapper {
);

applyPageDecorations(viewer: Viewer, pageDecorations: V2PageDecoration[]) {
pageDecorations = [
{
page_number: 1,
title: 'Title for page 1',
website_link: 'https://shop.rema1000.dk/varer/304718'
},
{
page_number: 2,
title: 'Title for page 2',
website_link: 'https://shop.rema1000.dk/varer/304718',
website_link_title: 'Rema1000'
},
{
page_number: 3,
title: 'Title for page 3',
website_link: '',
website_link_title: 'Rema1000',
hotspots: [
{
x1: 0,
x2: 1,
y1: 0,
y2: 0.47,
type: 'embed',
link: 'https://www.youtube.com/embed/z9Ud_-Y3iHY?si=VsN9IHfChY0cgUYs&controls=0&autoplay=1&mute=1'
}
]
},
{
page_number: 4,
title: 'Title for page 4',
website_link: 'https://shop.rema1000.dk/varer/304718',
website_link_title: 'Website title'
},
{
page_number: 5,
title: 'Title for page 5',
website_link: 'https://shop.rema1000.dk/varer/400176',
website_link_title: 'Website link title',
hotspots: [
{
x1: 0.425,
x2: 1,
y1: 0.09,
y2: 0.68,
type: 'link',
link: 'https://shop.rema1000.dk/varer/400176'
}
]
}
];

viewer.applyPageDecorations(pageDecorations);
}
}
6 changes: 0 additions & 6 deletions lib/kits/paged-publication/viewer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,7 @@ class Viewer extends MicroEvent {
PageDecorations().render({
pageDecorations: currentPageDecorations,
aspectRatio: this.options?.hotspotRatio || 1,
versoPageSpread,
versoPageSpreads: this._core.getVerso().pageSpreads,
pageSpread: currentPageSpread,
pageSpreads: this._core.pageSpreads.collection
});
}
Expand All @@ -360,19 +358,15 @@ class Viewer extends MicroEvent {
PageDecorations().render({
pageDecorations: pageDecors,
aspectRatio: this.options?.hotspotRatio || 1,
versoPageSpread,
versoPageSpreads: this._core.getVerso().pageSpreads,
pageSpread: currentPageSpread,
pageSpreads: this._core.pageSpreads.collection
});

this._core.bind('resized', (e) => {
PageDecorations().render({
pageDecorations: pageDecors,
aspectRatio: this.options?.hotspotRatio || 1,
versoPageSpread,
versoPageSpreads: this._core.getVerso().pageSpreads,
pageSpread: currentPageSpread,
pageSpreads: this._core.pageSpreads.collection
});
});
Expand Down

0 comments on commit cdb5f60

Please sign in to comment.