Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#267 Add useScroll #278

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open

#267 Add useScroll #278

wants to merge 2 commits into from

Conversation

Evgen4ikk
Copy link

No description provided.

@Evgen4ikk Evgen4ikk changed the title Add useScroll #267 Add useScroll Jan 25, 2025
});

useEffect(() => {
if (element.current) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

скобки лишние

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

даже бахни так - if(!element.current) return и ниже что внутри скобок

@@ -0,0 +1,202 @@
import { type RefObject, useEffect, useRef, useState } from 'react';

import { debounce as DebounceFn, throttle as ThrottleFn } from '@/utils/helpers';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

с маленькой буквы фанки

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

даже можешь заюзать так чтобы не было повторных неймов * as helpers from '@/utils/helpers'

и ниже helper.debounce() и тд

}
}, throttle + idle);

const onScrollHandler = useEvent((e: Event) => {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

не e а event - буквы бесплатны


const onScrollEnd = DebounceFn((e: Event) => {
const currentTime = Date.now();
if (currentTime - lastScrollTime.current >= idle) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут можно тоже предусмотреть чтобы сразу выйти типо if(currentTime - lastScrollTime.current < idle) return и ниже делать сеты

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants