UNPKG

@trap_stevo/legendarybuilderproreact-ui

Version:

The legendary UI & utility API that makes your application a legendary application. ~ Created by Steven Compton

30 lines (27 loc) 999 B
import _slicedToArray from "@babel/runtime/helpers/slicedToArray"; /* Created by Hassan Steven Compton. March 7, 2024. */ import * as React from 'react'; import { createContext, useContext, useState } from 'react'; var ScrollContext = /*#__PURE__*/createContext(); export var ScrollHandlingProvider = function ScrollHandlingProvider(_ref) { var children = _ref.children; var _useState = useState(0), _useState2 = _slicedToArray(_useState, 2), currentScrollPosition = _useState2[0], setCurrentScrollPosition = _useState2[1]; var updateCurrentScrollPosition = function updateCurrentScrollPosition(position) { setCurrentScrollPosition(position); }; return /*#__PURE__*/React.createElement(ScrollContext.Provider, { value: { currentScrollPosition: currentScrollPosition, updateCurrentScrollPosition: updateCurrentScrollPosition } }, children); }; export var useScroll = function useScroll() { return useContext(ScrollContext); };