react-mkx-toolkit
Advanced tools
Comparing version 1.5.5 to 1.5.6
{ | ||
"name": "react-mkx-toolkit", | ||
"version": "1.5.5", | ||
"version": "1.5.6", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./dist/index.js", |
@@ -128,3 +128,3 @@ ## React Custom Hooks | ||
function ScrollComponent() { | ||
const { scrollToTop, scrollToBottom, scrollToId } = useScroll(); | ||
const { scrollToTop, scrollToBottom, scrollById } = useScroll(); | ||
@@ -139,4 +139,4 @@ const handleScrollToTop = () => { | ||
const handleScrollToId = () => { | ||
scrollToId("myElementId", { | ||
const handleScrollById = () => { | ||
scrollById("myElementId", { | ||
behavior: "smooth", | ||
@@ -152,3 +152,3 @@ block: "start", | ||
<button onClick={handleScrollToBottom}>Scroll to Bottom</button> | ||
<button onClick={handleScrollToId}>Scroll to Element with ID</button> | ||
<button onClick={handleScrollById}>Scroll to Element with ID</button> | ||
<div id="myElementId">Element to scroll to</div> | ||
@@ -155,0 +155,0 @@ </div> |
@@ -1,2 +0,2 @@ | ||
export interface ScrollOptions { | ||
export interface ScrollOptionsProps { | ||
behavior?: "auto" | "instant" | "smooth"; | ||
@@ -6,1 +6,21 @@ block?: "start" | "center" | "end" | "nearest"; | ||
} | ||
export interface useScrollProps { | ||
/** | ||
* Scrolls the window to the top. | ||
* @returns {void} | ||
*/ | ||
scrollToTop: () => void; | ||
/** | ||
* Scrolls the window to the bottom. | ||
* @returns {void} | ||
*/ | ||
scrollToBottom: () => void; | ||
/** | ||
* Scrolls the window to an element with the specified ID, with customizable options. | ||
* @param {string} id - The ID of the element to scroll to. | ||
* @param {ScrollOptionsProps} options - Optional scroll options. | ||
* @returns {void} | ||
*/ | ||
scrollById: (id: string, options?: ScrollOptionsProps) => void; | ||
} |
@@ -1,31 +0,12 @@ | ||
import { ScrollOptions } from "./index.d"; | ||
import { ScrollOptionsProps, useScrollProps } from "./index.d"; | ||
/** | ||
* Hook to provide scrolling utilities. | ||
* @returns {ScrollFunctions} An object containing functions for scrolling. | ||
* @returns {useScrollProps} An object containing functions for scrolling. | ||
*/ | ||
interface ScrollFunctions { | ||
/** | ||
* Scrolls the window to the top. | ||
* @returns {void} | ||
*/ | ||
scrollToTop: () => void; | ||
/** | ||
* Scrolls the window to the bottom. | ||
* @returns {void} | ||
*/ | ||
scrollToBottom: () => void; | ||
/** | ||
* Scrolls the window to an element with the specified ID, with customizable options. | ||
* @param {string} id - The ID of the element to scroll to. | ||
* @param {ScrollOptions} options - Optional scroll options. | ||
* @returns {void} | ||
*/ | ||
scrollById: (id: string, options?: ScrollOptions) => void; | ||
} | ||
/** | ||
* Hook to provide scrolling utilities. | ||
* @returns {ScrollFunctions} An object containing functions for scrolling. | ||
* @returns {useScrollProps} An object containing functions for scrolling. | ||
*/ | ||
function useScroll(): ScrollFunctions { | ||
function useScroll(): useScrollProps { | ||
/** | ||
@@ -50,7 +31,7 @@ * Scrolls the window to the top. | ||
* @param {string} id - The ID of the element to scroll to. | ||
* @param {ScrollOptions} options - Optional scroll options. | ||
* @param {ScrollOptionsProps} options - Optional scroll options. | ||
* @returns {void} | ||
*/ | ||
const scrollById = (id: string, options?: ScrollOptions): void => { | ||
const defaultOptions: ScrollOptions = { | ||
const scrollById = (id: string, options?: ScrollOptionsProps): void => { | ||
const defaultOptions: ScrollOptionsProps = { | ||
behavior: "smooth", | ||
@@ -57,0 +38,0 @@ block: "center", |
Sorry, the diff of this file is not supported yet
25896