mirror of
https://github.com/amir20/dozzle.git
synced 2025-12-24 14:31:44 +01:00
28 lines
585 B
TypeScript
28 lines
585 B
TypeScript
type ScrollContext = {
|
|
paused: boolean;
|
|
progress: number;
|
|
currentDate: Date;
|
|
};
|
|
|
|
// export for testing
|
|
export const scrollContextKey = Symbol("scrollContext") as InjectionKey<ScrollContext>;
|
|
|
|
export const provideScrollContext = () => {
|
|
const context = defaultValue();
|
|
provide(scrollContextKey, context);
|
|
return context;
|
|
};
|
|
|
|
export const useScrollContext = () => {
|
|
const context = inject(scrollContextKey, defaultValue());
|
|
return toRefs(context);
|
|
};
|
|
|
|
function defaultValue() {
|
|
return reactive({
|
|
paused: false,
|
|
progress: 1,
|
|
currentDate: new Date(),
|
|
});
|
|
}
|