UNPKG

@itwin/core-react

Version:

A react component library of iTwin.js UI general purpose components

32 lines 1.15 kB
/*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Utilities */ import * as React from "react"; /** * Context used by Widgets and child components to process opacity changes based on mouse proximity. * @internal */ export const WidgetOpacityContext = React.createContext({ proximityScale: 1.0, addRef: () => { }, removeRef: () => { }, }); /** Hook for using [[WidgetOpacityContext]] * @internal */ export function useWidgetOpacityContext() { const ref = React.useRef(null); const { addRef, removeRef, proximityScale } = React.useContext(WidgetOpacityContext); React.useEffect(() => { addRef(ref); return () => { removeRef(ref); }; }, [addRef, removeRef]); return { ref, proximityScale }; } //# sourceMappingURL=useWidgetOpacityContext.js.map