@mobilon-dev/chotto 0.3.130 → 0.3.133

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,70 +1,97 @@
1
- import { ref as t, watch as g, unref as u, nextTick as y } from "vue";
2
- function L({
1
+ import { ref as r, watch as w, unref as s, nextTick as W } from "vue";
2
+ function x({
3
3
  feedRef: n,
4
- emit: i,
5
- isLoadingMoreRef: p,
6
- stickToBottomRef: h
4
+ emit: h,
5
+ isLoadingMoreRef: S,
6
+ stickToBottomRef: H
7
7
  }) {
8
- const s = t(!1), a = t(!1), f = t(!1), r = t(!1), S = t(0), T = t(0), c = t(!1), v = t(!1), m = () => !!(h && u(h)), B = (o = !0) => {
9
- const l = u(n);
10
- if (!l) return;
11
- const e = l.scrollHeight - l.scrollTop - l.clientHeight;
12
- r.value ? (l.scrollTop < 300 && !m() && (f.value = !1, s.value = !1), e < 300 && (a.value = !1, f.value = !0)) : o && (l.scrollTop < 300 && !m() && (S.value = l.scrollHeight, T.value = l.scrollTop, c.value = !0, s.value = !1), e < 300 && (a.value = !1));
13
- }, d = (o = 0) => {
14
- const l = () => {
15
- y(() => {
8
+ const t = r(!1), a = r(!1), p = r(!1), i = r(!1), T = r(0), d = r(0), u = r(!1), m = r(!1), F = () => !!(H && s(H)), B = (o = !0) => {
9
+ const e = s(n);
10
+ if (!e) return;
11
+ const l = e.scrollHeight - e.scrollTop - e.clientHeight;
12
+ i.value ? (e.scrollTop < 300 && !F() && (p.value = !1, t.value = !1), l < 300 && (a.value = !1, p.value = !0)) : o && (e.scrollTop < 300 && !F() && (T.value = e.scrollHeight, d.value = e.scrollTop, u.value = !0, t.value = !1), l < 300 && (a.value = !1));
13
+ }, L = (o = 0) => {
14
+ const e = () => {
15
+ W(() => {
16
16
  requestAnimationFrame(() => {
17
17
  try {
18
- const e = u(n);
19
- if (!e || !c.value) return;
20
- const w = e.style.scrollBehavior;
21
- e.style.scrollBehavior = "auto";
22
- const H = e.scrollHeight - S.value;
23
- e.scrollTop = T.value + H, setTimeout(() => {
24
- e.style.scrollBehavior = w || "auto";
18
+ const l = s(n);
19
+ if (!l || !u.value) return;
20
+ const f = l.style.scrollBehavior;
21
+ l.style.scrollBehavior = "auto";
22
+ const v = l.scrollHeight - T.value;
23
+ l.scrollTop = d.value + v, setTimeout(() => {
24
+ l.style.scrollBehavior = f || "auto";
25
25
  }, 50);
26
26
  } finally {
27
- c.value = !1, v.value = !0, setTimeout(() => {
28
- v.value = !1;
27
+ u.value = !1, m.value = !0, setTimeout(() => {
28
+ m.value = !1;
29
29
  }, 500);
30
30
  }
31
31
  });
32
32
  });
33
33
  };
34
- o > 0 ? setTimeout(l, o) : l();
34
+ o > 0 ? setTimeout(e, o) : e();
35
35
  };
36
- return i && g(
37
- () => [a.value, s.value],
36
+ h && w(
37
+ () => [a.value, t.value],
38
38
  () => {
39
- a.value || i("loadMoreDown"), s.value || i("loadMore");
39
+ a.value || h("loadMoreDown"), t.value || h("loadMore");
40
40
  }
41
- ), p && g(
42
- () => p.value,
43
- (o, l) => {
44
- l === !0 && o === !1 && d(0);
41
+ ), S && w(
42
+ () => S.value,
43
+ (o, e) => {
44
+ e === !0 && o === !1 && L(0);
45
45
  }
46
- ), {
47
- allowLoadMoreTop: s,
46
+ );
47
+ const M = (o) => {
48
+ const e = s(n);
49
+ if (!e) return;
50
+ (o.offsetX > e.clientWidth || o.offsetY > e.clientHeight) && (i.value = !0);
51
+ }, y = () => {
52
+ i.value = !1;
53
+ }, Y = () => {
54
+ t.value = !0, a.value = !0;
55
+ }, g = () => {
56
+ const o = s(n);
57
+ return !o || !t.value ? !1 : (T.value = o.scrollHeight, d.value = o.scrollTop, u.value = !0, t.value = !1, !0);
58
+ }, O = (o) => {
59
+ if (o.deltaY >= 0) return;
60
+ const e = s(n);
61
+ !e || !(e.scrollHeight <= e.clientHeight + 1) || t.value && g();
62
+ };
63
+ let c = null;
64
+ return {
65
+ allowLoadMoreTop: t,
48
66
  allowLoadMoreBottom: a,
49
- movingDown: f,
50
- isScrollByMouseButton: r,
51
- pendingTopRestore: c,
52
- topLoadJustHappened: v,
67
+ movingDown: p,
68
+ isScrollByMouseButton: i,
69
+ pendingTopRestore: u,
70
+ topLoadJustHappened: m,
53
71
  checkScrollPosition: B,
54
- restoreScrollPosition: d,
55
- startScrollWatch: (o) => {
56
- const l = u(n);
57
- if (!l) return;
58
- (o.offsetX > l.clientWidth || o.offsetY > l.clientHeight) && (r.value = !0);
72
+ restoreScrollPosition: L,
73
+ startScrollWatch: M,
74
+ stopScrollWatch: y,
75
+ resetAllowFlags: Y,
76
+ requestTopLoadFromUserGesture: g,
77
+ handleWheelForTopLoad: O,
78
+ handleTouchStartForTopLoad: (o) => {
79
+ var e;
80
+ c = ((e = o.touches[0]) == null ? void 0 : e.clientY) ?? null;
59
81
  },
60
- stopScrollWatch: () => {
61
- r.value = !1;
82
+ handleTouchMoveForTopLoad: (o) => {
83
+ var v;
84
+ if (c == null) return;
85
+ const e = s(n);
86
+ if (!e || !(e.scrollHeight <= e.clientHeight + 1)) return;
87
+ const f = (v = o.touches[0]) == null ? void 0 : v.clientY;
88
+ f != null && (f - c < 24 || t.value && (c = null, g()));
62
89
  },
63
- resetAllowFlags: () => {
64
- s.value = !0, a.value = !0;
90
+ handleTouchEndForTopLoad: () => {
91
+ c = null;
65
92
  }
66
93
  };
67
94
  }
68
95
  export {
69
- L as useFeedLoadMore
96
+ x as useFeedLoadMore
70
97
  };
@@ -1,38 +1,38 @@
1
- import { ref as f, watch as s, onUnmounted as p, nextTick as h } from "vue";
2
- const _ = 320;
3
- function F({ feedRef: u, objectsLengthRef: i }) {
4
- const n = f(0);
1
+ import { ref as p, watch as l, onUnmounted as h, nextTick as _ } from "vue";
2
+ const v = 8;
3
+ function g({ feedRef: i, objectsLengthRef: r }) {
4
+ const n = p(0);
5
5
  let e = null;
6
- function r() {
7
- const t = u.value;
8
- if (!t || i.value === 0) {
6
+ function a() {
7
+ const t = i.value;
8
+ if (!t || r.value === 0) {
9
9
  n.value = 0;
10
10
  return;
11
11
  }
12
- const c = t.querySelector(".message-feed__top-spacer"), m = (c == null ? void 0 : c.offsetHeight) ?? 0, d = t.scrollHeight - m, a = Math.max(0, t.clientHeight - d + _);
13
- a !== n.value && (n.value = a);
12
+ const c = t.querySelector(".message-feed__top-spacer"), f = (c == null ? void 0 : c.offsetHeight) ?? 0, d = t.scrollHeight - f, u = t.clientHeight - d, s = u > 0 && u <= v ? u + 1 : 0;
13
+ s !== n.value && (n.value = s);
14
14
  }
15
15
  function o() {
16
- h(() => {
16
+ _(() => {
17
17
  requestAnimationFrame(() => {
18
- r(), requestAnimationFrame(r);
18
+ a(), requestAnimationFrame(a);
19
19
  });
20
20
  });
21
21
  }
22
- function l(t) {
22
+ function m(t) {
23
23
  e == null || e.disconnect(), t && (e = new ResizeObserver(() => o()), e.observe(t));
24
24
  }
25
- return s(
26
- u,
25
+ return l(
26
+ i,
27
27
  (t) => {
28
- l(t), o();
28
+ m(t), o();
29
29
  },
30
30
  { immediate: !0 }
31
- ), s(
32
- i,
31
+ ), l(
32
+ r,
33
33
  () => o(),
34
34
  { immediate: !0 }
35
- ), p(() => {
35
+ ), h(() => {
36
36
  e == null || e.disconnect(), e = null;
37
37
  }), {
38
38
  topSpacerPx: n,
@@ -40,6 +40,6 @@ function F({ feedRef: u, objectsLengthRef: i }) {
40
40
  };
41
41
  }
42
42
  export {
43
- _ as FEED_TOP_LOAD_OVERFLOW_PX,
44
- F as useFeedTopSpacer
43
+ v as FEED_TOP_LOAD_OVERFLOW_PX,
44
+ g as useFeedTopSpacer
45
45
  };