diff options
author | dan <dan.abramov@gmail.com> | 2023-10-05 23:52:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-10-05 15:52:04 -0700 |
commit | 4ec5fabdd1c1b70fd8a3f5671c056bba3d38e174 (patch) | |
tree | 5452b0ec1f56d3857009f1df99c7985cbd4295c8 /src/view/com/lightbox/ImageViewing/index.tsx | |
parent | 260b03a05c22232373cbf8cb0d7dda41a3302343 (diff) | |
download | voidsky-4ec5fabdd1c1b70fd8a3f5671c056bba3d38e174.tar.zst |
Fix animations and gestures getting reset on state updates in the lightbox (#1618)
* Fix translation resetting on state update * Copy getImageStyles into iOS and Android forks * Fix opacity resetting on state update
Diffstat (limited to 'src/view/com/lightbox/ImageViewing/index.tsx')
-rw-r--r-- | src/view/com/lightbox/ImageViewing/index.tsx | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/src/view/com/lightbox/ImageViewing/index.tsx b/src/view/com/lightbox/ImageViewing/index.tsx index 3b659e2db..4b7208a22 100644 --- a/src/view/com/lightbox/ImageViewing/index.tsx +++ b/src/view/com/lightbox/ImageViewing/index.tsx @@ -69,11 +69,12 @@ function ImageViewing({ const imageList = useRef<VirtualizedList<ImageSource>>(null) const [opacity, setOpacity] = useState(1) const [currentImageIndex, setImageIndex] = useState(imageIndex) - - // TODO: It's not valid to reinitialize Animated values during render. - // This is a bug. - const headerTranslate = new Animated.ValueXY(INITIAL_POSITION) - const footerTranslate = new Animated.ValueXY(INITIAL_POSITION) + const [headerTranslate] = useState( + () => new Animated.ValueXY(INITIAL_POSITION), + ) + const [footerTranslate] = useState( + () => new Animated.ValueXY(INITIAL_POSITION), + ) const toggleBarsVisible = (isVisible: boolean) => { if (isVisible) { |