Scroom
IntroductionAPI ReferenceDebugUsage with ReactInstallationUsageExampleExamples

Usage with React

@scroom/react provides hooks to simplify usage.


Installation

$ npm install @scroom/react

Usage

import { useScroom, useDebug } from "@scroom/react";
import { useRef, useEffect } from "react";
function App() {
const ref = useRef();
const sc = useScroom(ref, {
offset: 0.5,
onProgress(e) {
console.log(e.progress);
},
});
// if you want to debug
useDebug(sc);
return <div ref={ref}>...</div>;
}

Example