mirror of
https://github.com/usatiuk/photos.git
synced 2025-10-28 23:37:48 +01:00
photos fade in
This commit is contained in:
@@ -19,7 +19,7 @@
|
|||||||
box-shadow: $pt-elevation-shadow-4;
|
box-shadow: $pt-elevation-shadow-4;
|
||||||
}
|
}
|
||||||
|
|
||||||
transition: transform 0.3s;
|
transition: all 0.3s;
|
||||||
}
|
}
|
||||||
|
|
||||||
#photoOverlayDrawer {
|
#photoOverlayDrawer {
|
||||||
|
|||||||
@@ -55,7 +55,6 @@ export const OverviewComponent: React.FunctionComponent<IOverviewComponentProps>
|
|||||||
e.currentTarget.scrollTop + e.currentTarget.clientHeight >=
|
e.currentTarget.scrollTop + e.currentTarget.clientHeight >=
|
||||||
e.currentTarget.scrollHeight - 100
|
e.currentTarget.scrollHeight - 100
|
||||||
) {
|
) {
|
||||||
console.log(props.allPhotosLoaded, props.overviewFetching);
|
|
||||||
if (!props.allPhotosLoaded && !props.overviewFetching) {
|
if (!props.allPhotosLoaded && !props.overviewFetching) {
|
||||||
props.fetchPhotos();
|
props.fetchPhotos();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,16 @@
|
|||||||
#photo {
|
#photo {
|
||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
max-width: 100%;
|
max-width: 100%;
|
||||||
|
|
||||||
|
&.notLoaded {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.loaded {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.bp3-dark {
|
.bp3-dark {
|
||||||
|
|||||||
@@ -20,6 +20,8 @@ export interface IPhotoComponentProps {
|
|||||||
export const PhotoComponent: React.FunctionComponent<IPhotoComponentProps> = (
|
export const PhotoComponent: React.FunctionComponent<IPhotoComponentProps> = (
|
||||||
props,
|
props,
|
||||||
) => {
|
) => {
|
||||||
|
const [loaded, setLoaded] = React.useState<boolean>(false);
|
||||||
|
|
||||||
if (!props.photo && !props.photoState?.fetching) {
|
if (!props.photo && !props.photoState?.fetching) {
|
||||||
props.fetchPhoto(props.id);
|
props.fetchPhoto(props.id);
|
||||||
}
|
}
|
||||||
@@ -36,6 +38,8 @@ export const PhotoComponent: React.FunctionComponent<IPhotoComponentProps> = (
|
|||||||
<img
|
<img
|
||||||
id="photo"
|
id="photo"
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
|
className={loaded ? "loaded" : "notLoaded"}
|
||||||
|
onLoad={() => setLoaded(true)}
|
||||||
src={getPhotoThumbPath(props.photo, 2048)}
|
src={getPhotoThumbPath(props.photo, 2048)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
13
frontend/src/Photos/PhotoCard.scss
Normal file
13
frontend/src/Photos/PhotoCard.scss
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
.photoCard {
|
||||||
|
img {
|
||||||
|
transition: all 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
.notLoaded {
|
||||||
|
opacity: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loaded {
|
||||||
|
opacity: 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
import "./PhotoCard.scss";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
Card,
|
Card,
|
||||||
ContextMenuTarget,
|
ContextMenuTarget,
|
||||||
@@ -23,15 +25,30 @@ export interface IPhotoCardComponentProps extends RouteComponentProps {
|
|||||||
onClick: () => void;
|
onClick: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface IPhotoCardComponentState {
|
||||||
|
loaded: boolean;
|
||||||
|
}
|
||||||
|
|
||||||
|
const defaultPhotoCardState: IPhotoCardComponentState = {
|
||||||
|
loaded: false,
|
||||||
|
};
|
||||||
|
|
||||||
@ContextMenuTarget
|
@ContextMenuTarget
|
||||||
export class PhotoCardComponent extends React.PureComponent<
|
export class PhotoCardComponent extends React.PureComponent<
|
||||||
IPhotoCardComponentProps
|
IPhotoCardComponentProps,
|
||||||
|
IPhotoCardComponentState
|
||||||
> {
|
> {
|
||||||
constructor(props: IPhotoCardComponentProps) {
|
constructor(props: IPhotoCardComponentProps) {
|
||||||
super(props);
|
super(props);
|
||||||
|
|
||||||
this.handleDelete = this.handleDelete.bind(this);
|
this.handleDelete = this.handleDelete.bind(this);
|
||||||
|
this.setLoaded = this.setLoaded.bind(this);
|
||||||
//this.handleEdit = this.handleEdit.bind(this);
|
//this.handleEdit = this.handleEdit.bind(this);
|
||||||
|
this.state = defaultPhotoCardState;
|
||||||
|
}
|
||||||
|
|
||||||
|
private setLoaded(loaded: boolean) {
|
||||||
|
this.setState({ ...this.state, loaded });
|
||||||
}
|
}
|
||||||
|
|
||||||
public handleDelete(): void {
|
public handleDelete(): void {
|
||||||
@@ -61,6 +78,8 @@ export class PhotoCardComponent extends React.PureComponent<
|
|||||||
<img
|
<img
|
||||||
loading="lazy"
|
loading="lazy"
|
||||||
src={getPhotoThumbPath(this.props.photo, 512)}
|
src={getPhotoThumbPath(this.props.photo, 512)}
|
||||||
|
className={this.state.loaded ? "loaded" : "notLoaded"}
|
||||||
|
onLoad={() => this.setLoaded(true)}
|
||||||
onMouseEnter={() =>
|
onMouseEnter={() =>
|
||||||
preloadImage(
|
preloadImage(
|
||||||
getPhotoThumbPath(this.props.photo, 2048),
|
getPhotoThumbPath(this.props.photo, 2048),
|
||||||
|
|||||||
Reference in New Issue
Block a user