@@ -187,10 +187,10 @@ index 6481228..0dc5dd1 100644
187187 padding,
188188 currentHeight,
189189diff --git a/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js b/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
190- index 827436c..fe9f371 100644
190+ index 11e81a9..de39eac 100644
191191--- a/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
192192+++ b/lib/commonjs/components/KeyboardChatScrollView/useExtraContentPadding/index.js
193- @@ -32 ,6 +32 ,8 @@ function useExtraContentPadding(options) {
193+ @@ -33 ,6 +33 ,8 @@ function useExtraContentPadding(options) {
194194 extraContentPadding,
195195 keyboardPadding,
196196 blankSpace,
@@ -199,7 +199,7 @@ index 827436c..fe9f371 100644
199199 scroll,
200200 layout,
201201 size,
202- @@ -66 ,8 +68 ,8 @@ function useExtraContentPadding(options) {
202+ @@ -74 ,8 +76 ,8 @@ function useExtraContentPadding(options) {
203203 }
204204
205205 // Compute effective delta considering blankSpace floor
@@ -210,20 +210,24 @@ index 827436c..fe9f371 100644
210210 const effectiveDelta = currentTotal - previousTotal;
211211 if (effectiveDelta === 0) {
212212 // blankSpace absorbed the change
213- @@ -86,13 +88,11 @@ function useExtraContentPadding(options) {
214- const target = Math.max(scroll.value - effectiveDelta, -currentTotal);
215- scrollToTarget( target);
213+ @@ -116,14 +118,15 @@ function useExtraContentPadding(options) {
214+ if (inverted) {
215+ target = Math.max(base - effectiveDelta, -currentTotal );
216216 } else {
217217- const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, 0);
218- - // Clamp at 0 as well: when the content is shorter than the viewport a
219- - // shrinking padding makes `effectiveDelta` negative while `scroll.value`
220- - // is already 0, so the target would go below the top of the content.
221- - const target = Math.max(Math.min(scroll.value + effectiveDelta, maxScroll), 0);
222218+ const minScroll = -adjustedStartInsetCompensation;
223219+ const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, minScroll);
224- + const target = Math.max(minScroll, Math.min(scroll.value + effectiveDelta, maxScroll));
225- scrollToTarget(target);
220+
221+ - // Clamp at 0 as well: when the content is shorter than the viewport a
222+ - // shrinking padding makes `effectiveDelta` negative while `base` is
223+ - // already 0, so the target would go below the top of the content.
224+ - target = Math.max(Math.min(base + effectiveDelta, maxScroll), 0);
225+ + // Clamp at the top as well: when the content is shorter than the
226+ + // viewport a shrinking padding makes `effectiveDelta` negative while
227+ + // `base` is already at the top.
228+ + target = Math.max(minScroll, Math.min(base + effectiveDelta, maxScroll));
226229 }
230+ scrollToTarget(target);
227231- }, [inverted, keyboardLiftBehavior]);
228232+ }, [inverted, keyboardLiftBehavior, adjustedInsetCompensation, adjustedStartInsetCompensation]);
229233 }
@@ -430,10 +434,10 @@ index 043b973..df5a408 100644
430434 padding,
431435 currentHeight,
432436diff --git a/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js b/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
433- index 3c90439..9e7ebb6 100644
437+ index cdca47b..3ea3a7f 100644
434438--- a/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
435439+++ b/lib/module/components/KeyboardChatScrollView/useExtraContentPadding/index.js
436- @@ -26 ,6 +26 ,8 @@ function useExtraContentPadding(options) {
440+ @@ -27 ,6 +27 ,8 @@ function useExtraContentPadding(options) {
437441 extraContentPadding,
438442 keyboardPadding,
439443 blankSpace,
@@ -442,7 +446,7 @@ index 3c90439..9e7ebb6 100644
442446 scroll,
443447 layout,
444448 size,
445- @@ -60 ,8 +62 ,8 @@ function useExtraContentPadding(options) {
449+ @@ -68 ,8 +70 ,8 @@ function useExtraContentPadding(options) {
446450 }
447451
448452 // Compute effective delta considering blankSpace floor
@@ -453,20 +457,24 @@ index 3c90439..9e7ebb6 100644
453457 const effectiveDelta = currentTotal - previousTotal;
454458 if (effectiveDelta === 0) {
455459 // blankSpace absorbed the change
456- @@ -80,14 +82,12 @@ function useExtraContentPadding(options) {
457- const target = Math.max(scroll.value - effectiveDelta, -currentTotal);
458- scrollToTarget( target);
460+ @@ -110,15 +112,16 @@ function useExtraContentPadding(options) {
461+ if (inverted) {
462+ target = Math.max(base - effectiveDelta, -currentTotal );
459463 } else {
460464- const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, 0);
461- - // Clamp at 0 as well: when the content is shorter than the viewport a
462- - // shrinking padding makes `effectiveDelta` negative while `scroll.value`
463- - // is already 0, so the target would go below the top of the content.
464- - const target = Math.max(Math.min(scroll.value + effectiveDelta, maxScroll), 0);
465465+ const minScroll = -adjustedStartInsetCompensation;
466466+ const maxScroll = Math.max(size.value.height - layout.value.height + currentTotal, minScroll);
467- + const target = Math.max(minScroll, Math.min(scroll.value + effectiveDelta, maxScroll));
468- scrollToTarget(target);
467+
468+ - // Clamp at 0 as well: when the content is shorter than the viewport a
469+ - // shrinking padding makes `effectiveDelta` negative while `base` is
470+ - // already 0, so the target would go below the top of the content.
471+ - target = Math.max(Math.min(base + effectiveDelta, maxScroll), 0);
472+ + // Clamp at the top as well: when the content is shorter than the
473+ + // viewport a shrinking padding makes `effectiveDelta` negative while
474+ + // `base` is already at the top.
475+ + target = Math.max(minScroll, Math.min(base + effectiveDelta, maxScroll));
469476 }
477+ scrollToTarget(target);
470478- }, [inverted, keyboardLiftBehavior]);
471479+ }, [inverted, keyboardLiftBehavior, adjustedInsetCompensation, adjustedStartInsetCompensation]);
472480 }
@@ -823,10 +831,10 @@ index f89b7c8..02e0e19 100644
823831
824832 type UseChatKeyboardReturn = {
825833diff --git a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
826- index e7584ed..dc653b0 100644
834+ index 99cc6c6..d883e76 100644
827835--- a/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
828836+++ b/src/components/KeyboardChatScrollView/useExtraContentPadding/index.ts
829- @@ -17 ,6 +17 ,10 @@ type UseExtraContentPaddingOptions = {
837+ @@ -18 ,6 +18 ,10 @@ type UseExtraContentPaddingOptions = {
830838 keyboardPadding: SharedValue<number>;
831839 /** Minimum inset floor — used to absorb keyboard and extraContentPadding changes. */
832840 blankSpace: SharedValue<number>;
@@ -837,7 +845,7 @@ index e7584ed..dc653b0 100644
837845 /** Current vertical scroll offset. */
838846 scroll: SharedValue<number>;
839847 /** Visible viewport dimensions. */
840- @@ -52 ,6 +56 ,8 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
848+ @@ -53 ,6 +57 ,8 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
841849 extraContentPadding,
842850 keyboardPadding,
843851 blankSpace,
@@ -846,7 +854,7 @@ index e7584ed..dc653b0 100644
846854 scroll,
847855 layout,
848856 size,
849- @@ -95 ,14 +101 ,12 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
857+ @@ -104 ,14 +110 ,12 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
850858 }
851859
852860 // Compute effective delta considering blankSpace floor
@@ -867,30 +875,28 @@ index e7584ed..dc653b0 100644
867875 const effectiveDelta = currentTotal - previousTotal;
868876
869877 if (effectiveDelta === 0) {
870- @@ -135,22 +139,28 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
871-
872- scrollToTarget( target);
878+ @@ -170,20 +174,26 @@ function useExtraContentPadding(options: UseExtraContentPaddingOptions): void {
879+ if (inverted) {
880+ target = Math.max(base - effectiveDelta, -currentTotal );
873881 } else {
874882+ const minScroll = -adjustedStartInsetCompensation;
875883 const maxScroll = Math.max(
876884 size.value.height - layout.value.height + currentTotal,
877885- 0,
878886+ minScroll,
879887 );
888+
880889- // Clamp at 0 as well: when the content is shorter than the viewport a
881- - // shrinking padding makes `effectiveDelta` negative while `scroll.value`
882- - // is already 0, so the target would go below the top of the content.
890+ - // shrinking padding makes `effectiveDelta` negative while `base` is
891+ - // already 0, so the target would go below the top of the content.
892+ - target = Math.max(Math.min(base + effectiveDelta, maxScroll), 0);
883893+ // Clamp at the top as well: when the content is shorter than the
884894+ // viewport a shrinking padding makes `effectiveDelta` negative while
885- + // `scroll.value` is already at the top.
886- const target = Math.max(
887- + minScroll,
888- Math.min(scroll.value + effectiveDelta, maxScroll),
889- - 0,
890- );
891-
892- scrollToTarget(target);
895+ + // `base` is already at the top.
896+ + target = Math.max(minScroll, Math.min(base + effectiveDelta, maxScroll));
893897 }
898+
899+ scrollToTarget(target);
894900 },
895901- [inverted, keyboardLiftBehavior],
896902+ [
0 commit comments