feat: useMouseWheel -> useScreenMouseWheel
This commit is contained in:
18
app/composables/useScreenMouseWheel.ts
Normal file
18
app/composables/useScreenMouseWheel.ts
Normal file
@@ -0,0 +1,18 @@
|
||||
export type ScreenMouseWheelCallback = (deltaY: number, deltaX: number) => void;
|
||||
|
||||
export const useScreenMouseWheel = (callback: ScreenMouseWheelCallback) => {
|
||||
const registerScreenMouseWheelCallback = inject<
|
||||
(callback: ScreenMouseWheelCallback) => () => void
|
||||
>("registerScreenMouseWheelCallback");
|
||||
|
||||
onMounted(() => {
|
||||
if (!registerScreenMouseWheelCallback) {
|
||||
throw new Error(
|
||||
"Missing registerScreenMouseWheelCallback - useScreenMouseWheel must be used within a Screen component",
|
||||
);
|
||||
}
|
||||
|
||||
const unregister = registerScreenMouseWheelCallback(callback);
|
||||
onUnmounted(unregister);
|
||||
});
|
||||
};
|
||||
Reference in New Issue
Block a user