@savvycal/calendar 0.11.1 → 0.11.2
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.
|
@@ -27,7 +27,10 @@ interface UseInitialScrollArgs {
|
|
|
27
27
|
* container, so they stay pinned and don't factor into `scrollTop`:
|
|
28
28
|
*
|
|
29
29
|
* clamped = clamp(initialScrollHour, startHour, endHour)
|
|
30
|
-
* scrollTop = (clamped - startHour) * effectiveHourHeight
|
|
30
|
+
* scrollTop = (clamped - startHour) * effectiveHourHeight + HOUR_LINE_WIDTH
|
|
31
|
+
*
|
|
32
|
+
* The extra `HOUR_LINE_WIDTH` tucks the hour's top border under the sticky
|
|
33
|
+
* header's bottom border, so the two don't stack into a double line.
|
|
31
34
|
*
|
|
32
35
|
* It only repositions on a `scrollKey` change — not on unrelated re-renders
|
|
33
36
|
* (events/availability arriving, selection, hover) or a resize re-measuring
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useInitialScroll.d.ts","sourceRoot":"","sources":["../../../src/components/shared/useInitialScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"useInitialScroll.d.ts","sourceRoot":"","sources":["../../../src/components/shared/useInitialScroll.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAKhE,UAAU,oBAAoB;IAC5B,iEAAiE;IACjE,OAAO,EAAE,SAAS,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IAC1C,8EAA8E;IAC9E,iBAAiB,EAAE,MAAM,GAAG,SAAS,CAAC;IACtC,iCAAiC;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,OAAO,EAAE,MAAM,CAAC;IAChB,0DAA0D;IAC1D,mBAAmB,EAAE,MAAM,CAAC;IAC5B;;;;OAIG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB,gFAAgF;IAChF,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,gBAAgB,CAAC,EAC/B,OAAO,EACP,iBAAiB,EACjB,SAAS,EACT,OAAO,EACP,mBAAmB,EACnB,eAAe,EACf,SAAS,GACV,EAAE,oBAAoB,GAAG,IAAI,CAgC7B"}
|
|
@@ -1,31 +1,32 @@
|
|
|
1
|
-
import { useRef as
|
|
2
|
-
|
|
1
|
+
import { useRef as I, useLayoutEffect as x } from "react";
|
|
2
|
+
const E = 1;
|
|
3
|
+
function M({
|
|
3
4
|
rootRef: u,
|
|
4
5
|
initialScrollHour: n,
|
|
5
6
|
startHour: t,
|
|
6
|
-
endHour:
|
|
7
|
-
effectiveHourHeight:
|
|
8
|
-
containerHeight:
|
|
7
|
+
endHour: c,
|
|
8
|
+
effectiveHourHeight: f,
|
|
9
|
+
containerHeight: m,
|
|
9
10
|
scrollKey: e
|
|
10
11
|
}) {
|
|
11
|
-
const
|
|
12
|
-
|
|
12
|
+
const r = I(null);
|
|
13
|
+
x(() => {
|
|
13
14
|
if (n == null || !Number.isFinite(n))
|
|
14
15
|
return;
|
|
15
16
|
const s = u.current;
|
|
16
|
-
if (!s ||
|
|
17
|
-
const p = Math.min(Math.max(n, t),
|
|
18
|
-
s.scrollTop = (p - t) *
|
|
17
|
+
if (!s || m <= 0 || r.current === e) return;
|
|
18
|
+
const p = Math.min(Math.max(n, t), c);
|
|
19
|
+
s.scrollTop = (p - t) * f + E, r.current = e;
|
|
19
20
|
}, [
|
|
20
21
|
u,
|
|
21
22
|
n,
|
|
22
23
|
t,
|
|
24
|
+
c,
|
|
23
25
|
f,
|
|
24
26
|
m,
|
|
25
|
-
r,
|
|
26
27
|
e
|
|
27
28
|
]);
|
|
28
29
|
}
|
|
29
30
|
export {
|
|
30
|
-
|
|
31
|
+
M as useInitialScroll
|
|
31
32
|
};
|