import react from 'react'; import MouseInfoProvider from '@faceless-ui/mouse-info; export const MyApp = () = ( <MouseInfoProvider> ... </MouseInfoProvider> );
childrenReact children.
xCurrent mouse position along the x-axis
yCurrent mouse position along the y-axis
xDifferenceLast number of pixels moved along the x-axis
yDifferenceLast number of pixels moved along the y-axis
xDirectionDirection of the last mouse movement along the x-axis
yDirectionDirection of the last mouse movement along the y-axis
xPercentagePercentage moved along the x-axis
yPercentagePercentage moved along the y-axis
totalPercentagePercentage moved along the both and x and y-axes
eventsFiredNumber of animation frames completed
isInViewportToggled as the mouse enters and leaves the viewport
This is a hook you can use to access the context.
import react from 'react'; import { useMouseInfo } from '@faceless-ui/mouse-info; export const MyComponent = () => { const mouseInfo = useMouseInfo(); return ( ... ) };
This is a higher-order component you can use to access the context.
import react from 'react'; import { withMouseInfo } from '@faceless-ui/mouse-info; export const MyComponent = withMouseInfo((props) => { const { mouseInfo } = props; return ( ... ) };
All types can be directly imported.
import { MouseInfoProviderProps, MouseInfoProps, IMouseInfoContext } from '@faceless-ui/mouse-info/dist/types';