diff options
author | Marc Rousavy <marcrousavy@hotmail.com> | 2024-11-14 19:37:41 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-14 19:37:41 +0000 |
commit | 05312cce33006a11b7f000f84f94dc58b25e165d (patch) | |
tree | 2399fcb544943ca129c90564d9d1e32c3d23a3f4 /src | |
parent | 7d34f6bb5c47724b01336eaced7909426be1bdda (diff) | |
download | voidsky-05312cce33006a11b7f000f84f94dc58b25e165d.tar.zst |
feat: Tweak shared element animation to make it much smoother (#6336)
Diffstat (limited to 'src')
-rw-r--r-- | src/view/com/lightbox/ImageViewing/index.tsx | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/src/view/com/lightbox/ImageViewing/index.tsx b/src/view/com/lightbox/ImageViewing/index.tsx index e9bc1523d..37a9aa140 100644 --- a/src/view/com/lightbox/ImageViewing/index.tsx +++ b/src/view/com/lightbox/ImageViewing/index.tsx @@ -32,6 +32,7 @@ import Animated, { useSharedValue, withDecay, withSpring, + WithSpringConfig, } from 'react-native-reanimated' import { Edge, @@ -62,8 +63,18 @@ const EDGES = ? (['top', 'bottom', 'left', 'right'] satisfies Edge[]) : (['left', 'right'] satisfies Edge[]) // iOS, so no top/bottom safe area -const SLOW_SPRING = {stiffness: isIOS ? 180 : 250} -const FAST_SPRING = {stiffness: 700} +const SLOW_SPRING: WithSpringConfig = { + mass: isIOS ? 1.5 : 1, + damping: 300, + stiffness: 800, + restDisplacementThreshold: 0.01, +} +const FAST_SPRING: WithSpringConfig = { + mass: isIOS ? 1.5 : 1, + damping: 150, + stiffness: 900, + restDisplacementThreshold: 0.01, +} export default function ImageViewRoot({ lightbox: nextLightbox, @@ -706,7 +717,7 @@ function interpolateTransform( } } -function withClampedSpring(value: any, {stiffness}: {stiffness: number}) { +function withClampedSpring(value: any, config: WithSpringConfig) { 'worklet' - return withSpring(value, {overshootClamping: true, stiffness}) + return withSpring(value, {...config, overshootClamping: true}) } |