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:
1.0 KB
|
Line | |
---|
1 | "use strict";
|
---|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
---|
3 | var react_1 = require("react");
|
---|
4 | var util_1 = require("./misc/util");
|
---|
5 | var useScrolling = function (ref) {
|
---|
6 | var _a = react_1.useState(false), scrolling = _a[0], setScrolling = _a[1];
|
---|
7 | react_1.useEffect(function () {
|
---|
8 | if (ref.current) {
|
---|
9 | var scrollingTimeout_1;
|
---|
10 | var handleScrollEnd_1 = function () {
|
---|
11 | setScrolling(false);
|
---|
12 | };
|
---|
13 | var handleScroll_1 = function () {
|
---|
14 | setScrolling(true);
|
---|
15 | clearTimeout(scrollingTimeout_1);
|
---|
16 | scrollingTimeout_1 = setTimeout(function () { return handleScrollEnd_1(); }, 150);
|
---|
17 | };
|
---|
18 | util_1.on(ref.current, 'scroll', handleScroll_1, false);
|
---|
19 | return function () {
|
---|
20 | if (ref.current) {
|
---|
21 | util_1.off(ref.current, 'scroll', handleScroll_1, false);
|
---|
22 | }
|
---|
23 | };
|
---|
24 | }
|
---|
25 | return function () { };
|
---|
26 | }, [ref]);
|
---|
27 | return scrolling;
|
---|
28 | };
|
---|
29 | exports.default = useScrolling;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.