File size: 1,151 Bytes
541cc7d
 
 
 
1140b5d
 
 
 
 
 
 
 
541cc7d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1140b5d
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
class ScreenScroller {
    constructor() {
        this.is_user_scrolling = false;
    }
    bind() {
        let self = this;
        $("#chat-session-container").on("wheel touchmove", function () {
            if ($("#send-user-input").attr("status") === "stop") {
                self.set_user_scrolling(true);
            }
        });
    }
    get_user_scrolling() {
        return this.is_user_scrolling;
    }
    set_user_scrolling(val = true) {
        this.is_user_scrolling = val;
    }
    scroll_to_bottom(animate = false) {
        if (this.get_user_scrolling()) {
            return;
        }
        if (animate) {
            $("#chat-session-container").animate(
                {
                    scrollTop: $("#chat-session-container").prop(
                        "scrollHeight"
                    ),
                },
                500
            );
        } else {
            $("#chat-session-container").prop(
                "scrollTop",
                $("#chat-session-container").prop("scrollHeight")
            );
        }
    }
}

export let screen_scroller = new ScreenScroller();
screen_scroller.bind();