Files
notesnook/apps/mobile/src/utils/animations.js

149 lines
3.1 KiB
JavaScript
Raw Normal View History

2020-03-03 09:49:54 +05:00
import Animated, {Easing} from 'react-native-reanimated';
import {Dimensions} from 'react-native';
2020-03-03 15:21:44 +05:00
import {editing} from './utils';
2020-03-03 09:49:54 +05:00
const {color, Value, timing} = Animated;
export const EditorPosition = new Value(Dimensions.get('window').width * 1.5);
2020-05-12 02:56:22 +05:00
export const EditorScale = new Value(0.99);
2020-05-03 16:28:48 +05:00
export const EditorOpacity = new Value(0);
2020-05-21 18:18:32 +05:00
export const EditorTranslateY = new Value(10);
2020-05-03 16:28:48 +05:00
2020-03-03 09:49:54 +05:00
export function openEditorAnimation() {
2020-03-17 15:19:19 +05:00
EditorPosition.setValue(Dimensions.get('window').width * 1.5);
2020-05-21 18:18:32 +05:00
EditorTranslateY.setValue(10);
2020-05-03 16:28:48 +05:00
EditorOpacity.setValue(0);
2020-03-03 14:45:49 +05:00
editing.currentlyEditing = true;
2020-03-03 09:49:54 +05:00
let openConfigH = {
2020-05-03 16:28:48 +05:00
duration: 1,
2020-03-03 09:49:54 +05:00
toValue: 0,
2020-05-03 16:28:48 +05:00
easing: Easing.in(Easing.linear),
2020-03-03 09:49:54 +05:00
};
2020-05-03 16:28:48 +05:00
2020-05-12 02:56:22 +05:00
timing(EditorScale, {
duration:300,
toValue:1,
easing: Easing.in(Easing.linear),
}).start();
2020-05-21 18:18:32 +05:00
timing(EditorTranslateY, {
duration:300,
toValue:0,
easing: Easing.in(Easing.linear),
}).start();
2020-05-03 16:28:48 +05:00
timing(EditorOpacity, {
2020-05-12 02:56:22 +05:00
duration:50,
2020-05-03 16:28:48 +05:00
toValue:1,
easing: Easing.in(Easing.linear),
}).start();
2020-03-03 09:49:54 +05:00
timing(EditorPosition, openConfigH).start();
}
export function exitEditorAnimation() {
2020-03-17 15:19:19 +05:00
EditorPosition.setValue(0);
2020-05-03 16:28:48 +05:00
EditorOpacity.setValue(1);
2020-05-21 18:18:32 +05:00
EditorTranslateY.setValue(0);
2020-03-03 14:45:49 +05:00
editing.currentlyEditing = false;
2020-03-03 09:49:54 +05:00
let openConfigH = {
2020-05-03 16:28:48 +05:00
duration: 1,
2020-03-03 09:49:54 +05:00
toValue: Dimensions.get('window').width * 1.5,
2020-05-03 16:28:48 +05:00
easing: Easing.in(Easing.linear),
2020-03-03 09:49:54 +05:00
};
2020-05-03 16:28:48 +05:00
timing(EditorOpacity, {
duration:150,
2020-05-03 16:28:48 +05:00
toValue:0,
easing: Easing.in(Easing.linear),
}).start();
2020-05-21 18:18:32 +05:00
timing(EditorTranslateY, {
duration:150,
toValue:40,
easing: Easing.in(Easing.linear),
}).start();
2020-05-12 02:56:22 +05:00
timing(EditorScale, {
duration:150,
toValue:0.99,
easing: Easing.in(Easing.linear),
}).start();
2020-03-03 09:49:54 +05:00
timing(EditorPosition, openConfigH).start();
}
2020-01-07 16:26:30 +05:00
export const slideRight = {
0: {
transform: [{translateX: -4}],
},
0.5: {
transform: [{translateX: 0}],
},
1: {
transform: [{translateX: 4}],
},
};
export const slideLeft = {
0: {
transform: [{translateX: 4}],
},
0.5: {
transform: [{translateX: 0}],
},
1: {
transform: [{translateX: -4}],
},
};
export const rotate = {
0: {
transform: [{rotateZ: '0deg'}, {translateX: 0}, {translateY: 0}],
},
0.5: {
transform: [{rotateZ: '25deg'}, {translateX: 10}, {translateY: -20}],
},
1: {
transform: [{rotateZ: '45deg'}, {translateX: 10}, {translateY: -20}],
},
};
export const deleteItems = (tX, tY) => {
return {
0: {
2020-02-11 20:07:36 +05:00
transform: [
{translateX: tX},
{translateY: tY},
{scaleX: 0.6},
{scaleY: 0.6},
],
opacity: 0,
2020-01-07 16:26:30 +05:00
},
0.3: {
2020-02-11 20:07:36 +05:00
transform: [
{translateX: 0},
{translateY: 0},
{scaleX: 0.8},
{scaleY: 0.8},
],
opacity: 0.7,
2020-01-07 16:26:30 +05:00
},
0.5: {
2020-02-11 20:07:36 +05:00
transform: [{translateX: 0}, {translateY: 50}, {scaleX: 1}, {scaleY: 1}],
opacity: 0.9,
2020-01-07 16:26:30 +05:00
},
1: {
2020-02-11 20:07:36 +05:00
transform: [
{translateX: 0},
{translateY: 110},
{scaleX: 0.6},
{scaleY: 0.6},
],
opacity: 0,
2020-01-07 16:26:30 +05:00
},
};
};
export const opacity = {
0: {
opacity: 0,
},
1: {
opacity: 1,
},
};