Skip to content

Commit fa735d8

Browse files
authored
Merge pull request #3 from yekta/master
Use Easing.out on closeAnimation
2 parents 10b73d2 + 872f73a commit fa735d8

File tree

1 file changed

+44
-36
lines changed

1 file changed

+44
-36
lines changed

package/src/utilities.ts

Lines changed: 44 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,59 @@
1-
import { TextInput } from "react-native"
2-
import Animated, { Easing } from "react-native-reanimated";
1+
import {TextInput} from 'react-native';
2+
import Animated, {Easing} from 'react-native-reanimated';
33

44
export async function measureFocusedInputBottomYAsync() {
5-
return new Promise<number>(resolve=>{
6-
const input = TextInput.State.currentlyFocusedInput();
7-
if(!input) return;
8-
input.measure((x, y, width, height, pageX, pageY)=>{
9-
resolve(pageY + height);
10-
})
11-
})
5+
return new Promise<number>(resolve => {
6+
const input = TextInput.State.currentlyFocusedInput();
7+
if (!input) return;
8+
input.measure((x, y, width, height, pageX, pageY) => {
9+
resolve(pageY + height);
10+
});
11+
});
1212
}
1313

14-
export function measureFocusedInputBottomY(callback: (bottomY: number)=>void) {
15-
const input = TextInput.State.currentlyFocusedInput();
16-
if(!input) return;
17-
input.measure((x, y, width, height, pageX, pageY)=>{
18-
callback(pageY + height);
19-
})
14+
export function measureFocusedInputBottomY(
15+
callback: (bottomY: number) => void,
16+
) {
17+
const input = TextInput.State.currentlyFocusedInput();
18+
if (!input) return;
19+
input.measure((x, y, width, height, pageX, pageY) => {
20+
callback(pageY + height);
21+
});
2022
}
2123

2224
export function measureInputBottomYAsync() {
23-
return new Promise<number>(resolve=>{
24-
measureFocusedInputBottomY(resolve)
25-
})
25+
return new Promise<number>(resolve => {
26+
measureFocusedInputBottomY(resolve);
27+
});
2628
}
2729

2830
export function calcAndroidSystemPan({
29-
keyboardEndY,
30-
inputBottomY,
31-
} : {
32-
keyboardEndY: number,
33-
inputBottomY: number
31+
keyboardEndY,
32+
inputBottomY,
33+
}: {
34+
keyboardEndY: number;
35+
inputBottomY: number;
3436
}) {
35-
const delta = inputBottomY - keyboardEndY;
36-
return Math.max(0, delta);
37+
const delta = inputBottomY - keyboardEndY;
38+
return Math.max(0, delta);
3739
}
3840

39-
export function closeAnimation(duration: number, easing: Animated.EasingFunction) {
40-
return {
41-
duration: duration + 50,
42-
easing: Easing.in(easing)
43-
}
41+
export function closeAnimation(
42+
duration: number,
43+
easing: Animated.EasingFunction,
44+
) {
45+
return {
46+
duration: duration + 50,
47+
easing: Easing.out(easing),
48+
};
4449
}
4550

46-
export function openAnimation(duration: number, easing: Animated.EasingFunction) {
47-
return {
48-
duration,
49-
easing: Easing.out(easing)
50-
}
51-
}
51+
export function openAnimation(
52+
duration: number,
53+
easing: Animated.EasingFunction,
54+
) {
55+
return {
56+
duration,
57+
easing: Easing.out(easing),
58+
};
59+
}

0 commit comments

Comments
 (0)