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