aboutsummaryrefslogtreecommitdiff
path: root/app/src/web/ts/scroll_stop.ts
blob: 1ec6d30bcbe768329d636680c7e1b3c752ef0eac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// Listen when scrolling events stop
(function () {
    let scrollTimeout: number | undefined = undefined;
    let scrolling: boolean = false;

    window.addEventListener('scroll', function (event) {

        if (!scrolling) {
            Frost.setScrolling(true);
            scrolling = true;
        }

        window.clearTimeout(scrollTimeout);

        scrollTimeout = setTimeout(function () {
            if (scrolling) {
                Frost.setScrolling(false);
                scrolling = false;
            }
        }, 600);
        // For our specific use case, we want to release other features pretty far after scrolling stops
        // For general scrolling use cases, the delta can be much smaller
        // My assumption for context menus is that the long press is 500ms
    }, false);
}).call(undefined);