mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 04:46:40 +07:00
added experimental scroll helper
This commit is contained in:
parent
c2154e930c
commit
8d1e6989c2
8 changed files with 105 additions and 4 deletions
27
src/components/common/ScrollHelperBottom/index.tsx
Normal file
27
src/components/common/ScrollHelperBottom/index.tsx
Normal file
|
@ -0,0 +1,27 @@
|
|||
import React, { VFC } from 'react';
|
||||
import styles from './styles.module.scss';
|
||||
import { useScrollTop } from '~/hooks/dom/useScrollTop';
|
||||
import { useScrollHeight } from '~/hooks/dom/useScrollHeight';
|
||||
import classNames from 'classnames';
|
||||
import { useScrollToBottom } from '~/hooks/dom/useScrollToBottom';
|
||||
|
||||
interface ScrollHelperBottomProps {}
|
||||
|
||||
const ScrollHelperBottom: VFC<ScrollHelperBottomProps> = () => {
|
||||
const top = useScrollTop();
|
||||
const scrollHeight = useScrollHeight();
|
||||
const scrollToBottom = useScrollToBottom();
|
||||
|
||||
const isVisible = scrollHeight > 2000 && top < scrollHeight * 0.25;
|
||||
|
||||
return (
|
||||
<div
|
||||
className={classNames(styles.helper, { [styles.visible]: isVisible })}
|
||||
onClick={scrollToBottom}
|
||||
>
|
||||
Вниз
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export { ScrollHelperBottom };
|
Loading…
Add table
Add a link
Reference in a new issue