source: imaps-frontend/node_modules/react-use/esm/useScrolling.js@ d565449

main
Last change on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago

Update repo after prototype presentation

  • Property mode set to 100644
File size: 976 bytes
RevLine 
[d565449]1import { useEffect, useState } from 'react';
2import { off, on } from './misc/util';
3var useScrolling = function (ref) {
4 var _a = useState(false), scrolling = _a[0], setScrolling = _a[1];
5 useEffect(function () {
6 if (ref.current) {
7 var scrollingTimeout_1;
8 var handleScrollEnd_1 = function () {
9 setScrolling(false);
10 };
11 var handleScroll_1 = function () {
12 setScrolling(true);
13 clearTimeout(scrollingTimeout_1);
14 scrollingTimeout_1 = setTimeout(function () { return handleScrollEnd_1(); }, 150);
15 };
16 on(ref.current, 'scroll', handleScroll_1, false);
17 return function () {
18 if (ref.current) {
19 off(ref.current, 'scroll', handleScroll_1, false);
20 }
21 };
22 }
23 return function () { };
24 }, [ref]);
25 return scrolling;
26};
27export default useScrolling;
Note: See TracBrowser for help on using the repository browser.