UNPKG

1.47 kBJavaScriptView Raw
1import {useCallback as $nrdL2$useCallback} from "react";
2import {useEvent as $nrdL2$useEvent} from "@react-aria/utils";
3
4/*
5 * Copyright 2021 Adobe. All rights reserved.
6 * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License. You may obtain a copy
8 * of the License at http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software distributed under
11 * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12 * OF ANY KIND, either express or implied. See the License for the specific language
13 * governing permissions and limitations under the License.
14 */
15
16function $7d0a636d7a4dcefd$export$2123ff2b87c81ca(props, ref) {
17 let { onScroll: onScroll, isDisabled: isDisabled } = props;
18 let onScrollHandler = (0, $nrdL2$useCallback)((e)=>{
19 // If the ctrlKey is pressed, this is a zoom event, do nothing.
20 if (e.ctrlKey) return;
21 // stop scrolling the page
22 e.preventDefault();
23 e.stopPropagation();
24 if (onScroll) onScroll({
25 deltaX: e.deltaX,
26 deltaY: e.deltaY
27 });
28 }, [
29 onScroll
30 ]);
31 (0, $nrdL2$useEvent)(ref, 'wheel', isDisabled ? undefined : onScrollHandler);
32}
33
34
35export {$7d0a636d7a4dcefd$export$2123ff2b87c81ca as useScrollWheel};
36//# sourceMappingURL=useScrollWheel.module.js.map