From 87248ddf7fe534f1b5388c4d0dcd7ff1b4c81174 Mon Sep 17 00:00:00 2001 From: Samuel Newman Date: Thu, 5 Sep 2024 14:38:30 +0100 Subject: [PATCH] add layout animations to gallery --- src/state/models/media/gallery.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/state/models/media/gallery.ts b/src/state/models/media/gallery.ts index 9c8c13010d..1f80f6e38a 100644 --- a/src/state/models/media/gallery.ts +++ b/src/state/models/media/gallery.ts @@ -1,8 +1,10 @@ -import {makeAutoObservable, runInAction} from 'mobx' -import {ImageModel} from './image' +import {LayoutAnimation} from 'react-native' import {Image as RNImage} from 'react-native-image-crop-picker' -import {openPicker} from 'lib/media/picker' +import {makeAutoObservable, runInAction} from 'mobx' + import {getImageDim} from 'lib/media/manip' +import {openPicker} from 'lib/media/picker' +import {ImageModel} from './image' interface InitialImageUri { uri: string @@ -63,6 +65,7 @@ export class GalleryModel { } runInAction(() => { + LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) this.add(image) }) } @@ -76,6 +79,7 @@ export class GalleryModel { } remove(image: ImageModel) { + LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) const index = this.images.findIndex(image_ => image_.path === image.path) this.images.splice(index, 1) } @@ -90,6 +94,7 @@ export class GalleryModel { allowsMultipleSelection: true, }) + LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut) return await Promise.all( images.map(image => { this.add(image)