kelt-ui-kit-react 1.9.5 → 1.9.6
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.
- package/dist/index.js +311 -307
- package/package.json +1 -1
- package/src/expands/expand/expand.tsx +41 -39
package/package.json
CHANGED
|
@@ -67,10 +67,16 @@ export const Expand = ({
|
|
|
67
67
|
|
|
68
68
|
useEffect(() => {
|
|
69
69
|
if (active) {
|
|
70
|
-
const
|
|
70
|
+
const timer1 = setTimeout(() => {
|
|
71
71
|
scrollToHeader();
|
|
72
72
|
}, 100);
|
|
73
|
-
|
|
73
|
+
const timer2 = setTimeout(() => {
|
|
74
|
+
scrollToHeader();
|
|
75
|
+
}, 350);
|
|
76
|
+
return () => {
|
|
77
|
+
clearTimeout(timer1);
|
|
78
|
+
clearTimeout(timer2);
|
|
79
|
+
};
|
|
74
80
|
}
|
|
75
81
|
}, [active, scrollToHeader]);
|
|
76
82
|
|
|
@@ -86,47 +92,43 @@ export const Expand = ({
|
|
|
86
92
|
const expandElement = expandRef.current;
|
|
87
93
|
if (!expandElement) return;
|
|
88
94
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
const headerOffsetTop =
|
|
111
|
-
headerRect.top - parentRect.top + scrollParent.scrollTop;
|
|
112
|
-
|
|
113
|
-
// 2. Si on a déjà scrollé vers ou au-delà du header, on ne remonte JAMAIS
|
|
114
|
-
if (scrollParent.scrollTop >= headerOffsetTop - 5) {
|
|
115
|
-
if (targetRect.bottom > parentRect.bottom) {
|
|
116
|
-
target.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
95
|
+
const performScroll = () => {
|
|
96
|
+
let scrollParent: HTMLElement | null = expandElement.parentElement;
|
|
97
|
+
while (scrollParent) {
|
|
98
|
+
const style = window.getComputedStyle(scrollParent);
|
|
99
|
+
const isScrollable =
|
|
100
|
+
/(auto|scroll)/.test(style.overflow + style.overflowY) &&
|
|
101
|
+
scrollParent.scrollHeight > scrollParent.clientHeight;
|
|
102
|
+
|
|
103
|
+
if (isScrollable) {
|
|
104
|
+
const parentRect = scrollParent.getBoundingClientRect();
|
|
105
|
+
const headerRect = expandElement.getBoundingClientRect();
|
|
106
|
+
const headerOffsetTop =
|
|
107
|
+
headerRect.top - parentRect.top + scrollParent.scrollTop;
|
|
108
|
+
|
|
109
|
+
// Si on a déjà scrollé vers ou au-delà du header, on ne remonte JAMAIS au header
|
|
110
|
+
if (scrollParent.scrollTop >= headerOffsetTop - 10) {
|
|
111
|
+
const targetRect = target.getBoundingClientRect();
|
|
112
|
+
if (targetRect.bottom > parentRect.bottom) {
|
|
113
|
+
target.scrollIntoView({ behavior: "smooth", block: "nearest" });
|
|
114
|
+
}
|
|
115
|
+
return;
|
|
117
116
|
}
|
|
117
|
+
|
|
118
|
+
// Si on n'a pas encore scrollé jusqu'au header, on y va
|
|
119
|
+
scrollParent.scrollTo({
|
|
120
|
+
top: headerOffsetTop,
|
|
121
|
+
behavior: "smooth",
|
|
122
|
+
});
|
|
118
123
|
return;
|
|
119
124
|
}
|
|
120
|
-
|
|
121
|
-
// 3. Sinon, on scrolle vers le header
|
|
122
|
-
scrollParent.scrollTo({
|
|
123
|
-
top: headerOffsetTop,
|
|
124
|
-
behavior: "smooth",
|
|
125
|
-
});
|
|
126
|
-
return;
|
|
125
|
+
scrollParent = scrollParent.parentElement;
|
|
127
126
|
}
|
|
128
|
-
|
|
129
|
-
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
performScroll();
|
|
130
|
+
// Répéter après l'ouverture du clavier virtuel (spécifique tablettes / mobiles Android)
|
|
131
|
+
setTimeout(performScroll, 300);
|
|
130
132
|
}
|
|
131
133
|
},
|
|
132
134
|
[active],
|