mirror of
https://github.com/kingomarnajjar/flex-template-web.git
synced 2026-07-29 05:00:43 +10:00
SearchPage: load off-screen images after user has scrolled the page.
This commit is contained in:
parent
988bddddfd
commit
fc9c8d763c
2 changed files with 12 additions and 7 deletions
|
|
@ -1,14 +1,15 @@
|
|||
import React from 'react';
|
||||
import React, { Component } from 'react';
|
||||
import { string, func } from 'prop-types';
|
||||
import { FormattedMessage, intlShape, injectIntl } from 'react-intl';
|
||||
import classNames from 'classnames';
|
||||
import { NamedLink, ResponsiveImage } from '../../components';
|
||||
import { lazyLoadWithDimensions } from '../../util/contextHelpers';
|
||||
import { propTypes } from '../../util/types';
|
||||
import { formatMoney } from '../../util/currency';
|
||||
import { ensureListing, ensureUser } from '../../util/data';
|
||||
import { richText } from '../../util/richText';
|
||||
import { createSlug } from '../../util/urlHelpers';
|
||||
import config from '../../config';
|
||||
import { NamedLink, ResponsiveImage } from '../../components';
|
||||
|
||||
import css from './ListingCard.css';
|
||||
|
||||
|
|
@ -33,6 +34,13 @@ const priceData = (price, intl) => {
|
|||
return {};
|
||||
};
|
||||
|
||||
class ListingImage extends Component {
|
||||
render() {
|
||||
return <ResponsiveImage {...this.props} />;
|
||||
}
|
||||
}
|
||||
const LazyImage = lazyLoadWithDimensions(ListingImage, { loadAfterInitialRendering: 3000 });
|
||||
|
||||
export const ListingCardComponent = props => {
|
||||
const { className, rootClassName, intl, listing, renderSizes, setActiveListing } = props;
|
||||
const classes = classNames(rootClassName || css.root, className);
|
||||
|
|
@ -55,7 +63,7 @@ export const ListingCardComponent = props => {
|
|||
onMouseLeave={() => setActiveListing(null)}
|
||||
>
|
||||
<div className={css.aspectWrapper}>
|
||||
<ResponsiveImage
|
||||
<LazyImage
|
||||
rootClassName={css.rootForImage}
|
||||
alt={title}
|
||||
image={firstImage}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,9 @@ exports[`ListingCard matches snapshot 1`] = `
|
|||
onMouseLeave={[Function]}
|
||||
>
|
||||
<div>
|
||||
<ResponsiveImage
|
||||
<lazyLoadWithDimensions(ListingImage)
|
||||
alt="listing1 title"
|
||||
className={null}
|
||||
image={null}
|
||||
noImageMessage={null}
|
||||
rootClassName={null}
|
||||
sizes={null}
|
||||
variants={
|
||||
Array [
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue