upd: announcement
Deskripsi: - pagination scrooll load No Issues
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import { hookstate } from "@hookstate/core"
|
||||
import { IGlobalTema } from './type_global';
|
||||
import { RefObject } from "react";
|
||||
|
||||
export const pwd_key_config = "fchgvjknlmdfnbvghhujlaknsdvjbhknlkmsdbdyu567t8y9u30r4587638y9uipkoeghjvuyi89ipkoefmnrjbhtiu4or9ipkoemnjfbhjiuoijdklnjhbviufojkejnshbiuojijknehgruyu"
|
||||
export const globalRole = hookstate<string>('')
|
||||
@@ -24,4 +25,6 @@ export const TEMA = hookstate<IGlobalTema>({
|
||||
export const globalNotifPage = hookstate({
|
||||
load: false,
|
||||
category: ''
|
||||
})
|
||||
})
|
||||
|
||||
export const currentScroll = hookstate<RefObject<HTMLDivElement> | null>(null);
|
||||
38
src/module/_global/components/scroll_provider.tsx
Normal file
38
src/module/_global/components/scroll_provider.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
"use client";
|
||||
|
||||
import { useHookstate } from "@hookstate/core";
|
||||
import { useEffect, useRef } from "react";
|
||||
import { Box } from "@mantine/core";
|
||||
import { currentScroll } from "../bin/val_global";
|
||||
|
||||
export function ScrollProvider({ children }: { children: React.ReactNode }) {
|
||||
const containerRef = useRef<HTMLDivElement>(null);
|
||||
const { set } = useHookstate(currentScroll);
|
||||
|
||||
useEffect(() => {
|
||||
if (window) {
|
||||
const handleScroll = () => {
|
||||
if (containerRef.current) {
|
||||
set(containerRef);
|
||||
}
|
||||
};
|
||||
|
||||
const container = containerRef.current;
|
||||
container?.addEventListener("scroll", handleScroll);
|
||||
|
||||
return () => {
|
||||
container?.removeEventListener("scroll", handleScroll);
|
||||
};
|
||||
}
|
||||
}, [containerRef, set]);
|
||||
return (
|
||||
<Box
|
||||
h={"100vh"}
|
||||
style={{ overflow: "auto", position: "relative" }}
|
||||
ref={containerRef}
|
||||
>
|
||||
{children}
|
||||
</Box>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import MqttLoad from "./bin/mqtt_load";
|
||||
import prisma from "./bin/prisma";
|
||||
import { DIR, globalNotifPage, globalRole, pwd_key_config, TEMA } from "./bin/val_global";
|
||||
import { currentScroll, DIR, globalNotifPage, globalRole, pwd_key_config, TEMA } from "./bin/val_global";
|
||||
import SkeletonAvatar from "./components/skeleton_avatar";
|
||||
import SkeletonDetailDiscussionComment from "./components/skeleton_detail_discussion_comment";
|
||||
import SkeletonDetailDiscussionMember from "./components/skeleton_detail_discussion_member";
|
||||
@@ -24,6 +24,7 @@ import ReloadButtonTop from "./components/reload_button_top";
|
||||
import ViewFilter from "./view/view_filter";
|
||||
import mtqq_client from "./bin/mqtt_client"
|
||||
import NotificationCustome from "./components/notification_custome";
|
||||
import { ScrollProvider } from "./components/scroll_provider";
|
||||
|
||||
export { WARNA };
|
||||
export { LayoutLogin };
|
||||
@@ -55,3 +56,5 @@ export { globalNotifPage }
|
||||
export { SkeletonAvatar }
|
||||
export { ReloadButtonTop }
|
||||
export { NotificationCustome }
|
||||
export { ScrollProvider }
|
||||
export { currentScroll }
|
||||
|
||||
Reference in New Issue
Block a user