mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-28 20:53:24 +10:00
lazyLoadWithDimensions: configure to work with aspect ratio images
This commit is contained in:
parent
6eca916bff
commit
915dae75e7
1 changed files with 5 additions and 2 deletions
|
|
@ -79,7 +79,7 @@ export const withViewport = Component => {
|
|||
*
|
||||
* @return {Object} HOC component which knows its dimensions
|
||||
*/
|
||||
export const lazyLoadWithDimensions = (Component, options) => {
|
||||
export const lazyLoadWithDimensions = (Component, options = {}) => {
|
||||
// The resize event is flooded when the browser is resized. We'll
|
||||
// use a small timeout to throttle changing the viewport since it
|
||||
// will trigger rerendering.
|
||||
|
|
@ -159,7 +159,10 @@ export const lazyLoadWithDimensions = (Component, options) => {
|
|||
const { maxWidth, maxHeight } = options;
|
||||
const maxWidthMaybe = maxWidth ? { maxWidth } : {};
|
||||
const maxHeightMaybe = maxHeight ? { maxHeight } : {};
|
||||
const style = { width: '100%', height: '100%', ...maxWidthMaybe, ...maxHeightMaybe };
|
||||
const style =
|
||||
maxWidth || maxHeight
|
||||
? { width: '100%', height: '100%', ...maxWidthMaybe, ...maxHeightMaybe }
|
||||
: { position: 'absolute', top: 0, right: 0, bottom: 0, left: 0 };
|
||||
|
||||
return (
|
||||
<div
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue