mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-22 22:49:45 +01:00
fix on scroll event
This commit is contained in:
@@ -27,7 +27,7 @@ const AnimatedTouchableOpacity = Animatable.createAnimatableComponent(
|
||||
);
|
||||
|
||||
const AnimatedSafeAreaView = Animatable.createAnimatableComponent(SafeAreaView);
|
||||
|
||||
let previousOffset = 0;
|
||||
export const Container = ({
|
||||
children,
|
||||
bottomButtonOnPress,
|
||||
@@ -55,31 +55,21 @@ export const Container = ({
|
||||
const [hideHeader, setHideHeader] = useState(false);
|
||||
const [buttonHide, setButtonHide] = useState(false);
|
||||
const insets = useSafeArea();
|
||||
let offsetY = 0;
|
||||
let countUp = 1;
|
||||
let countDown = 0;
|
||||
|
||||
let searchResult = [];
|
||||
|
||||
const onScroll = y => {
|
||||
const onScroll = currentOffset => {
|
||||
if (searchResults.length > 0) return;
|
||||
if (y < 30) {
|
||||
countUp = 1;
|
||||
countDown = 0;
|
||||
setHideHeader(false);
|
||||
}
|
||||
|
||||
if (y > offsetY) {
|
||||
if (y - offsetY < 150 || countDown > 0) return;
|
||||
countDown = 1;
|
||||
countUp = 0;
|
||||
if (currentOffset > previousOffset) {
|
||||
console.log('call A', currentOffset, previousOffset);
|
||||
|
||||
setHideHeader(true);
|
||||
} else {
|
||||
if (offsetY - y < 50 || countUp > 0) return;
|
||||
countDown = 0;
|
||||
countUp = 1;
|
||||
console.log('call B', currentOffset, previousOffset);
|
||||
setHideHeader(false);
|
||||
}
|
||||
offsetY = y;
|
||||
previousOffset = currentOffset;
|
||||
};
|
||||
|
||||
const onChangeText = value => {
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { TextInput } from 'react-native';
|
||||
import Animated, { Easing } from 'react-native-reanimated';
|
||||
import React, {useEffect, useState} from 'react';
|
||||
import {TextInput} from 'react-native';
|
||||
import Animated, {Easing} from 'react-native-reanimated';
|
||||
import Icon from 'react-native-vector-icons/MaterialCommunityIcons';
|
||||
import { br, SIZE, WEIGHT } from '../../common/common';
|
||||
import { useTracked } from '../../provider';
|
||||
import { inputRef } from '../../utils/refs';
|
||||
import { DDS } from '../../utils/utils';
|
||||
import {br, SIZE, WEIGHT} from '../../common/common';
|
||||
import {useTracked} from '../../provider';
|
||||
import {inputRef} from '../../utils/refs';
|
||||
import {DDS} from '../../utils/utils';
|
||||
|
||||
const { Value, timing, block } = Animated;
|
||||
const {Value, timing, block} = Animated;
|
||||
|
||||
export const Search = props => {
|
||||
const [state, dispatch] = useTracked();
|
||||
const { colors, searchResults } = state;
|
||||
const {colors, searchResults} = state;
|
||||
|
||||
const [focus, setFocus] = useState(false);
|
||||
|
||||
@@ -46,7 +46,7 @@ export const Search = props => {
|
||||
height: 60,
|
||||
justifyContent: 'center',
|
||||
marginTop: _marginAnim,
|
||||
paddingHorizontal: 12
|
||||
paddingHorizontal: 12,
|
||||
}}>
|
||||
<Animated.View
|
||||
transition={['borderWidth']}
|
||||
@@ -91,7 +91,7 @@ export const Search = props => {
|
||||
placeholderTextColor={colors.icon}
|
||||
/>
|
||||
<Icon
|
||||
style={{ paddingRight: DDS.isTab ? 12 : 12 }}
|
||||
style={{paddingRight: DDS.isTab ? 12 : 12}}
|
||||
onPress={() => {
|
||||
props.onSubmitEditing();
|
||||
}}
|
||||
|
||||
@@ -40,7 +40,6 @@ const SimpleList = ({
|
||||
const _onScroll = event => {
|
||||
if (!event) return;
|
||||
let y = event.nativeEvent.contentOffset.y;
|
||||
|
||||
eSendEvent(eScrollEvent, y);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user