diff --git a/frontend/src/Photos/Overview.scss b/frontend/src/Photos/Overview.scss index c6e9490..a4af609 100644 --- a/frontend/src/Photos/Overview.scss +++ b/frontend/src/Photos/Overview.scss @@ -19,7 +19,7 @@ box-shadow: $pt-elevation-shadow-4; } - transition: transform 0.3s; + transition: all 0.3s; } #photoOverlayDrawer { diff --git a/frontend/src/Photos/Overview.tsx b/frontend/src/Photos/Overview.tsx index b5b4f5f..a2736c8 100644 --- a/frontend/src/Photos/Overview.tsx +++ b/frontend/src/Photos/Overview.tsx @@ -55,7 +55,6 @@ export const OverviewComponent: React.FunctionComponent e.currentTarget.scrollTop + e.currentTarget.clientHeight >= e.currentTarget.scrollHeight - 100 ) { - console.log(props.allPhotosLoaded, props.overviewFetching); if (!props.allPhotosLoaded && !props.overviewFetching) { props.fetchPhotos(); } diff --git a/frontend/src/Photos/Photo.scss b/frontend/src/Photos/Photo.scss index 63a83cb..b8baa61 100644 --- a/frontend/src/Photos/Photo.scss +++ b/frontend/src/Photos/Photo.scss @@ -9,7 +9,16 @@ #photo { max-height: 100%; max-width: 100%; + + &.notLoaded { + opacity: 0; + } + + &.loaded { + opacity: 1; + } } + } .bp3-dark { diff --git a/frontend/src/Photos/Photo.tsx b/frontend/src/Photos/Photo.tsx index 19bb128..60139a7 100644 --- a/frontend/src/Photos/Photo.tsx +++ b/frontend/src/Photos/Photo.tsx @@ -20,6 +20,8 @@ export interface IPhotoComponentProps { export const PhotoComponent: React.FunctionComponent = ( props, ) => { + const [loaded, setLoaded] = React.useState(false); + if (!props.photo && !props.photoState?.fetching) { props.fetchPhoto(props.id); } @@ -36,6 +38,8 @@ export const PhotoComponent: React.FunctionComponent = ( setLoaded(true)} src={getPhotoThumbPath(props.photo, 2048)} /> diff --git a/frontend/src/Photos/PhotoCard.scss b/frontend/src/Photos/PhotoCard.scss new file mode 100644 index 0000000..a7dc393 --- /dev/null +++ b/frontend/src/Photos/PhotoCard.scss @@ -0,0 +1,13 @@ +.photoCard { + img { + transition: all 0.3s; + } + + .notLoaded { + opacity: 0; + } + + .loaded { + opacity: 1; + } +} \ No newline at end of file diff --git a/frontend/src/Photos/PhotoCard.tsx b/frontend/src/Photos/PhotoCard.tsx index 86f3cb5..ae074d5 100644 --- a/frontend/src/Photos/PhotoCard.tsx +++ b/frontend/src/Photos/PhotoCard.tsx @@ -1,3 +1,5 @@ +import "./PhotoCard.scss"; + import { Card, ContextMenuTarget, @@ -23,15 +25,30 @@ export interface IPhotoCardComponentProps extends RouteComponentProps { onClick: () => void; } +export interface IPhotoCardComponentState { + loaded: boolean; +} + +const defaultPhotoCardState: IPhotoCardComponentState = { + loaded: false, +}; + @ContextMenuTarget export class PhotoCardComponent extends React.PureComponent< - IPhotoCardComponentProps + IPhotoCardComponentProps, + IPhotoCardComponentState > { constructor(props: IPhotoCardComponentProps) { super(props); this.handleDelete = this.handleDelete.bind(this); + this.setLoaded = this.setLoaded.bind(this); //this.handleEdit = this.handleEdit.bind(this); + this.state = defaultPhotoCardState; + } + + private setLoaded(loaded: boolean) { + this.setState({ ...this.state, loaded }); } public handleDelete(): void { @@ -61,6 +78,8 @@ export class PhotoCardComponent extends React.PureComponent< this.setLoaded(true)} onMouseEnter={() => preloadImage( getPhotoThumbPath(this.props.photo, 2048),