Skip to content

Commit

Permalink
добработал компонентус. можно адыхать... .......................
Browse files Browse the repository at this point in the history
  • Loading branch information
VanyaMate committed Aug 7, 2024
1 parent ff4970b commit 0fd47c4
Show file tree
Hide file tree
Showing 6 changed files with 278 additions and 105 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.image {
height : 300px;
max-height : 300px;
max-width : 100%;
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ export const useVirtualList = function (props: UseVirtualListProps) {
getVirtualList({ index: currentIndex.current, list, showAmount }),
);

const setIndex = useCallback<VirtualIndexSetter>((index: number) => {
const setIndex = useCallback<VirtualIndexSetter>((index: number, list: VirtualList, showAmount: number) => {
currentIndex.current = index;
setVirtualList(
getVirtualList({ index, list, showAmount }),
);
}, [ list, showAmount ]);
}, []);

return { currentIndex, virtualList, setIndex };
};
9 changes: 8 additions & 1 deletion src/shared/ui-kit/box/Virtual/types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export enum VirtualScrollDirection {
}


export type VirtualIndexSetter = (index: number) => void;
export type VirtualIndexSetter = (index: number, list: VirtualList, showAmount: number) => void;

export enum VirtualType {
TOP,
Expand All @@ -35,3 +35,10 @@ export enum VirtualType {
export type VirtualList = Array<unknown>;
export type VirtualUploadMethod = () => Promise<unknown>;
export type VirtualRenderMethod = (item: unknown, index: number) => ReactNode;
export type VirtualScrollTo = (target: number, smooth: boolean, animationMs: number) => void;

export type VirtualElementProps = {
currentIndex: MutableRefObject<number>;
toFirstItem: () => void;
}
export type VirtualElement = (props: VirtualElementProps) => ReactNode;
42 changes: 32 additions & 10 deletions src/shared/ui-kit/box/Virtual/ui/Virtual.module.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
.container {
overflow : hidden;
width : 100%;
height : 100%;
position : relative;
overflow : hidden;
width : 100%;
height : 100%;
position : relative;
display : flex;
flex-direction : column-reverse;

.scrollContainer {
overflow : hidden;
width : 100%;
height : 100%;
flex : 1;
display : flex;
flex-direction : column-reverse;
transition : var(--transition-fast);
Expand Down Expand Up @@ -41,27 +43,47 @@
}

.loader {
position : absolute;
visibility : hidden;
opacity : 0;
height : 0;
transition : var(--transition-fast);
left : 50%;
top : 0;
transform : translate(-50%, -100%);

&.loading {
opacity : 1;
visibility : visible;
height : fit-content;
width : fit-content;
opacity : 1;
transform : translate(-50%, 0);
}

&.bottom {
top : 100%;
transform : translate(-50%, 0);

&.loading {
transform : translate(-50%, -100%);
}
}
}

.permanent {
width : 100%;
}

&.top {
flex-direction : column;

.scrollContainer,
.scrollBar {
flex-direction : column;
}
}

&.scrollable {
.scrollContainer {
.scrollContainer,
.permanent,
.loader {
padding-right : 12px;
}

Expand Down
Loading

0 comments on commit 0fd47c4

Please sign in to comment.