@artsy/palette-mobile 17.31.0 → 17.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/Image/Image.js +20 -25
- package/package.json +1 -1
|
@@ -1,29 +1,24 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import FastImage from "@d11/react-native-fast-image";
|
|
3
|
-
import { memo,
|
|
4
|
-
import { PixelRatio, View } from "react-native";
|
|
3
|
+
import { memo, useRef } from "react";
|
|
4
|
+
import { PixelRatio, View, Animated } from "react-native";
|
|
5
5
|
import { Blurhash } from "react-native-blurhash";
|
|
6
|
-
import Animated, { Easing, useAnimatedStyle, useSharedValue, withTiming, } from "react-native-reanimated";
|
|
7
6
|
import { createGeminiUrl } from "../../utils/createGeminiUrl";
|
|
8
7
|
import { useColor } from "../../utils/hooks";
|
|
9
8
|
import { useScreenDimensions } from "../../utils/hooks/useScreenDimensions";
|
|
10
9
|
import { Flex } from "../Flex";
|
|
11
10
|
import { Skeleton, SkeletonBox } from "../Skeleton";
|
|
12
11
|
export const Image = memo(({ aspectRatio, width, height, performResize = true, src, style, resizeMode, geminiResizeMode, showLoadingState = false, blurhash, ...flexProps }) => {
|
|
13
|
-
const loading = useSharedValue(true);
|
|
14
12
|
const dimensions = useImageDimensions({ aspectRatio, width, height });
|
|
15
13
|
const color = useColor();
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
// No need to get the js thread involved here
|
|
25
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
26
|
-
}, []);
|
|
14
|
+
const opacity = useRef(new Animated.Value(0)).current;
|
|
15
|
+
const onLoadEnd = () => {
|
|
16
|
+
Animated.timing(opacity, {
|
|
17
|
+
toValue: 1,
|
|
18
|
+
duration: 200,
|
|
19
|
+
useNativeDriver: true,
|
|
20
|
+
}).start();
|
|
21
|
+
};
|
|
27
22
|
if (showLoadingState) {
|
|
28
23
|
return (_jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }));
|
|
29
24
|
}
|
|
@@ -36,16 +31,16 @@ export const Image = memo(({ aspectRatio, width, height, performResize = true, s
|
|
|
36
31
|
resizeMode: geminiResizeMode,
|
|
37
32
|
});
|
|
38
33
|
}
|
|
39
|
-
return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [_jsx(View, { style: [dimensions, { position: "absolute" }], children: _jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }) }), _jsx(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
34
|
+
return (_jsxs(Flex, { position: "relative", ...flexProps, style: { ...dimensions }, children: [_jsx(View, { style: [dimensions, { position: "absolute" }], children: _jsx(ImageSkeleton, { dimensions: dimensions, blurhash: blurhash, style: { position: "absolute" } }) }), _jsx(FastImage, { style: [
|
|
35
|
+
dimensions,
|
|
36
|
+
style,
|
|
37
|
+
// If we have a blurhash, we don't want to show a background color
|
|
38
|
+
// That might flash before the image loads
|
|
39
|
+
{ backgroundColor: blurhash ? "transparent" : color("mono30") },
|
|
40
|
+
], resizeMode: resizeMode, onLoadEnd: onLoadEnd, source: {
|
|
41
|
+
priority: FastImage.priority.normal,
|
|
42
|
+
uri,
|
|
43
|
+
} })] }));
|
|
49
44
|
});
|
|
50
45
|
const useImageDimensions = (props) => {
|
|
51
46
|
const screenDimensions = useScreenDimensions();
|
package/package.json
CHANGED