Skip to content

A fully open source & end-to-end encrypted note taking alternative to Evernote.

add support for layout animations

ammarahm-edce39561a64ef
diff --git a/apps/mobile/src/utils/layoutmanager.js b/apps/mobile/src/utils/layoutmanager.js
new file mode 100644
index 000000000..4f45e8cad
--- /dev/null
+++ b/apps/mobile/src/utils/layoutmanager.js
@@ -0,0 +1,36 @@
+import SettingsService from '../services/SettingsService';
+
+const {LayoutAnimation} = require('react-native');
+
+function withAnimation(duration = 300) {
+ if (SettingsService.get().reduceAnimations) return;
+ LayoutAnimation.configureNext(
+ LayoutAnimation.create(duration, 'linear', 'opacity')
+ );
+}
+
+function withSpringAnimation(duration = 300) {
+ if (SettingsService.get().reduceAnimations) return;
+ LayoutAnimation.configureNext({
+ duration: duration,
+ create: {
+ type: LayoutAnimation.Types.linear,
+ property: LayoutAnimation.Properties.opacity,
+ duration: duration / 2
+ },
+ update: {
+ type: LayoutAnimation.Types.spring,
+ springDamping: 0.8
+ },
+ delete: {
+ type: LayoutAnimation.Types.easeOut,
+ property: LayoutAnimation.Properties.opacity,
+ duration: duration / 2
+ }
+ });
+}
+
+export default {
+ withAnimation,
+ withSpringAnimation
+};