mirror of
https://github.com/streetwriters/notesnook.git
synced 2025-12-23 15:09:33 +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 => {
|
||||
|
||||
@@ -46,7 +46,7 @@ export const Search = props => {
|
||||
height: 60,
|
||||
justifyContent: 'center',
|
||||
marginTop: _marginAnim,
|
||||
paddingHorizontal: 12
|
||||
paddingHorizontal: 12,
|
||||
}}>
|
||||
<Animated.View
|
||||
transition={['borderWidth']}
|
||||
|
||||
@@ -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