mirror of
https://github.com/Studio-Saelix/sencho.git
synced 2026-08-30 03:59:41 +00:00
c8a54a988b
- Replace catch (error: any) with catch (error) + (error as Error).message cast in EditorLayout, NodeManager, HomeDashboard, AppStoreView - Define TemplateVolume interface in AppStoreView; replace volumes any[] with typed array - Define MetricPoint interface in HomeDashboard; replace metrics any[] with MetricPoint[] - Define TerminalContainer type in BashExecModal; replace as any DOM property casts - Define NodeTestInfo interface in NodeManager; replace info: any with typed shape - Fix DockerNetworkStats cast in EditorLayout container stats WebSocket handler - Remove unused catch variable (e) in api.ts and other components - Cast streamFilter onValueChange val to union type in GlobalObservabilityView - Add eslint-disable-next-line react-refresh/only-export-components to badge.tsx, button.tsx, AuthContext, NodeContext, use-data-state, use-is-in-view - Add eslint-disable-next-line react-hooks/set-state-in-effect in LogViewer - Add /* eslint-disable */ to animate-ui third-party primitive files
27 lines
816 B
TypeScript
27 lines
816 B
TypeScript
import * as React from 'react';
|
|
import { useInView, type UseInViewOptions } from 'motion/react';
|
|
|
|
interface UseIsInViewOptions {
|
|
inView?: boolean;
|
|
inViewOnce?: boolean;
|
|
inViewMargin?: UseInViewOptions['margin'];
|
|
}
|
|
|
|
function useIsInView<T extends HTMLElement = HTMLElement>(
|
|
ref: React.Ref<T>,
|
|
options: UseIsInViewOptions = {},
|
|
) {
|
|
const { inView, inViewOnce = false, inViewMargin = '0px' } = options;
|
|
const localRef = React.useRef<T>(null);
|
|
React.useImperativeHandle(ref, () => localRef.current as T);
|
|
const inViewResult = useInView(localRef, {
|
|
once: inViewOnce,
|
|
margin: inViewMargin,
|
|
});
|
|
const isInView = !inView || inViewResult;
|
|
return { ref: localRef, isInView };
|
|
}
|
|
|
|
// eslint-disable-next-line react-refresh/only-export-components
|
|
export { useIsInView, type UseIsInViewOptions };
|