Optimize core animations
This commit is contained in:
parent
69b61d1244
commit
b3162eae86
@ -1,8 +1,8 @@
|
|||||||
import { Photo } from '@/photo';
|
import { Photo } from '@/photo';
|
||||||
import { absolutePathForCameraImage, pathForCamera } from '@/site/paths';
|
import { absolutePathForCameraImage, pathForCamera } from '@/site/paths';
|
||||||
import OGTile from '@/components/OGTile';
|
import OGTile from '@/components/OGTile';
|
||||||
import { Camera, titleForCamera } from '.';
|
import { Camera } from '.';
|
||||||
import { descriptionForCameraPhotos } from './meta';
|
import { descriptionForCameraPhotos, titleForCamera } from './meta';
|
||||||
|
|
||||||
export type OGLoadingState = 'unloaded' | 'loading' | 'loaded' | 'failed';
|
export type OGLoadingState = 'unloaded' | 'loading' | 'loaded' | 'failed';
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ export const descriptionForCameraPhotos = (
|
|||||||
photos: Photo[],
|
photos: Photo[],
|
||||||
dateBased?: boolean,
|
dateBased?: boolean,
|
||||||
) =>
|
) =>
|
||||||
descriptionForPhotoSet(photos, 'camera', dateBased);
|
descriptionForPhotoSet(photos, undefined, dateBased);
|
||||||
|
|
||||||
export const generateMetaForCamera = (
|
export const generateMetaForCamera = (
|
||||||
camera: Camera,
|
camera: Camera,
|
||||||
|
|||||||
@ -62,16 +62,15 @@ function AnimateItems({
|
|||||||
switch (typeResolved) {
|
switch (typeResolved) {
|
||||||
case 'left': return {
|
case 'left': return {
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
translateX: distanceOffset,
|
transform: `translateX(${distanceOffset}px)`,
|
||||||
};
|
};
|
||||||
case 'right': return {
|
case 'right': return {
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
translateX: -distanceOffset,
|
transform: `translateX(${-distanceOffset}px)`,
|
||||||
};
|
};
|
||||||
default: return {
|
default: return {
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
scale: scaleOffset,
|
transform: `translateY(${distanceOffset}px) scale(${scaleOffset})`,
|
||||||
translateY: distanceOffset,
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -99,14 +98,12 @@ function AnimateItems({
|
|||||||
<motion.div
|
<motion.div
|
||||||
key={index}
|
key={index}
|
||||||
className={classNameItem}
|
className={classNameItem}
|
||||||
style={getInitialVariant()}
|
// style={getInitialVariant()}
|
||||||
variants={{
|
variants={{
|
||||||
hidden: getInitialVariant(),
|
hidden: getInitialVariant(),
|
||||||
show: {
|
show: {
|
||||||
opacity: 1,
|
opacity: 1,
|
||||||
scale: 1,
|
transform: 'translateX(0) translateY(0) scale(1)',
|
||||||
translateX: 0,
|
|
||||||
translateY: 0,
|
|
||||||
},
|
},
|
||||||
}}
|
}}
|
||||||
transition={{
|
transition={{
|
||||||
|
|||||||
@ -177,12 +177,16 @@ export const photoQuantityText = (photos: Photo[]) =>
|
|||||||
|
|
||||||
export const descriptionForPhotoSet = (
|
export const descriptionForPhotoSet = (
|
||||||
photos:Photo[],
|
photos:Photo[],
|
||||||
descriptor: string,
|
descriptor?: string,
|
||||||
dateBased?: boolean,
|
dateBased?: boolean,
|
||||||
) =>
|
) =>
|
||||||
dateBased
|
dateBased
|
||||||
? dateRangeForPhotos(photos).description.toUpperCase()
|
? dateRangeForPhotos(photos).description.toUpperCase()
|
||||||
: `${photos.length} ${descriptor} ${labelForPhotos(photos)}`;
|
: [
|
||||||
|
photos.length,
|
||||||
|
descriptor,
|
||||||
|
labelForPhotos(photos),
|
||||||
|
].join(' ');
|
||||||
|
|
||||||
export const dateRangeForPhotos = (photos: Photo[]) => {
|
export const dateRangeForPhotos = (photos: Photo[]) => {
|
||||||
const start = photos[0].takenAtNaiveFormattedShort;
|
const start = photos[0].takenAtNaiveFormattedShort;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user