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
This commit is contained in:
dan 2023-10-05 23:52:04 +01:00 committed by GitHub
parent 260b03a05c
commit 4ec5fabdd1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 57 additions and 42 deletions

View file

@ -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) {