forked from vergnet/application-amicale
Fixed velocity prop not available on iOS
This commit is contained in:
parent
44f7a99bea
commit
0cbd263801
1 changed files with 6 additions and 4 deletions
|
@ -21,6 +21,8 @@ export default class AutoHideComponent extends React.Component<Props, State> {
|
|||
downAnimation;
|
||||
upAnimation;
|
||||
|
||||
lastOffset: number;
|
||||
|
||||
state = {
|
||||
fabPosition: new Animated.Value(0),
|
||||
};
|
||||
|
@ -30,9 +32,8 @@ export default class AutoHideComponent extends React.Component<Props, State> {
|
|||
}
|
||||
|
||||
onScroll({nativeEvent}: Object) {
|
||||
if (nativeEvent.velocity === undefined)
|
||||
return;
|
||||
if (nativeEvent.velocity.y > 0.2) { // Go down
|
||||
const speed = this.lastOffset - nativeEvent.contentOffset.y;
|
||||
if (speed < -5) { // Go down
|
||||
if (!this.isAnimationDownPlaying) {
|
||||
this.isAnimationDownPlaying = true;
|
||||
if (this.isAnimationUpPlaying)
|
||||
|
@ -46,7 +47,7 @@ export default class AutoHideComponent extends React.Component<Props, State> {
|
|||
this.isAnimationDownPlaying = false
|
||||
});
|
||||
}
|
||||
} else if (nativeEvent.velocity.y < -0.2) { // Go up
|
||||
} else if (speed > 5) { // Go up
|
||||
if (!this.isAnimationUpPlaying) {
|
||||
this.isAnimationUpPlaying = true;
|
||||
if (this.isAnimationDownPlaying)
|
||||
|
@ -61,6 +62,7 @@ export default class AutoHideComponent extends React.Component<Props, State> {
|
|||
});
|
||||
}
|
||||
}
|
||||
this.lastOffset = nativeEvent.contentOffset.y;
|
||||
}
|
||||
|
||||
render() {
|
||||
|
|
Loading…
Reference in a new issue