import react from 'react'; import ScrollInfoProvider from '@faceless-ui/scroll-info; export const MyApp = () = ( <ScrollInfoProvider> ... </ScrollInfoProvider> );
children*React children.
xCurrent scroll position along the x-axis
yCurrent scroll position along the y-axis
xDifferenceLast number of pixels scrolled along the x-axis
yDifferenceLast number of pixels scrolled along the y-axis
xPercentagePercentage scrolled along the x-axis
yPercentagePercentage scrolled along the y-axis
totalPercentagePercentage scrolled along the both and x and y-axes
eventsFiredNumber of animation frames completed
This is a hook you can use to access the context.
import react from 'react'; import { useScrollInfo } from '@faceless-ui/scroll-info; export const MyComponent = () => { const scrollInfo = useScrollInfo(); return ( ... ) };
This is a higher-order component you can use to access the context.
import react from 'react'; import { withScrollInfo } from '@faceless-ui/scroll-info; export const MyComponent = withScrollInfo((props) => { const { scrollInfo } = props; return ( ... ) };
All types can be directly imported.
import { ScrollInfoProviderProps, ScrollInfoProps, IScrollInfoContext } from '@faceless-ui/scroll-info/dist/types';