forked from stutrek/scrollmonitor
-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.ts
21 lines (18 loc) · 754 Bytes
/
index.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
export { ScrollMonitorContainer } from './src/container.js';
export { Watcher } from './src/watcher.js';
export * from './src/types';
import { isInBrowser } from './src/constants.js';
import { ScrollMonitorContainer } from './src/container.js';
// this is needed for the type, but if we're not in a browser the only
// way listenToDOM will be called is if you call scrollmonitor.createContainer
// and you can't do that until you have a DOM element.
const scrollMonitor = new ScrollMonitorContainer(
isInBrowser ? document.body : (undefined as unknown as HTMLElement)
);
if (isInBrowser) {
scrollMonitor.updateState();
scrollMonitor.listenToDOM();
//@ts-ignore
window.scrollMonitor = scrollMonitor;
}
export default scrollMonitor;