Properly center images in "single page mode"
While the reader width was set images weren't centered correctly in the images wrapper element
This commit is contained in:
@@ -97,7 +97,7 @@ export const ReaderPage = forwardRef(
|
|||||||
...applyStyles(!display, {
|
...applyStyles(!display, {
|
||||||
display: 'none',
|
display: 'none',
|
||||||
}),
|
}),
|
||||||
...getImageMarginStyling(readingMode.value, doublePage, position),
|
...getImageMarginStyling(doublePage, position),
|
||||||
...applyStyles(marginTop !== undefined, {
|
...applyStyles(marginTop !== undefined, {
|
||||||
mt: `${marginTop}px`,
|
mt: `${marginTop}px`,
|
||||||
}),
|
}),
|
||||||
@@ -119,7 +119,7 @@ export const ReaderPage = forwardRef(
|
|||||||
objectFit: 'contain',
|
objectFit: 'contain',
|
||||||
objectPosition: position,
|
objectPosition: position,
|
||||||
userSelect: 'none',
|
userSelect: 'none',
|
||||||
...getImageMarginStyling(readingMode.value, doublePage, position),
|
...getImageMarginStyling(doublePage, position),
|
||||||
...applyStyles(marginTop !== undefined, {
|
...applyStyles(marginTop !== undefined, {
|
||||||
mt: `${marginTop}px`,
|
mt: `${marginTop}px`,
|
||||||
}),
|
}),
|
||||||
|
|||||||
@@ -205,21 +205,12 @@ export const getImageWidthStyling = (
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
export const getImageMarginStyling = (
|
export const getImageMarginStyling = (doublePage: boolean, objectFitPosition?: 'left' | 'right'): CSSObject => ({
|
||||||
readingMode: IReaderSettings['readingMode'],
|
m: 'auto',
|
||||||
doublePage: boolean,
|
...applyStyles(doublePage, {
|
||||||
objectFitPosition?: 'left' | 'right',
|
// the applied margin is the opposite of the objectFitPosition
|
||||||
): CSSObject => ({
|
...applyStyles(objectFitPosition === 'right', { ml: 'auto ' }),
|
||||||
...applyStyles(!isContinuousReadingMode(readingMode), {
|
...applyStyles(objectFitPosition === 'left', { mr: 'auto ' }),
|
||||||
my: 'auto',
|
|
||||||
...applyStyles(doublePage, {
|
|
||||||
// the applied margin is the opposite of the objectFitPosition
|
|
||||||
...applyStyles(objectFitPosition === 'right', { ml: 'auto ' }),
|
|
||||||
...applyStyles(objectFitPosition === 'left', { mr: 'auto ' }),
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
...applyStyles(isContinuousReadingMode(readingMode), {
|
|
||||||
m: 'auto',
|
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user