@legendapp/list 3.0.0-beta.42 → 3.0.0-beta.43

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/keyboard.js CHANGED
@@ -84,6 +84,8 @@ var KeyboardAvoidingLegendList = reactNative.typedForwardRef(function KeyboardAv
84
84
  const didInteractive = reactNativeReanimated.useSharedValue(false);
85
85
  const shouldUpdateAlignItemsAtEndMinSize = reactNativeReanimated.useSharedValue(false);
86
86
  const isKeyboardOpen = reactNativeReanimated.useSharedValue(false);
87
+ const hasSeenKeyboardTransition = reactNativeReanimated.useSharedValue(false);
88
+ const skipKeyboardAnimationForCurrentTransition = reactNativeReanimated.useSharedValue(false);
87
89
  const keyboardInsetRef = React.useRef(0);
88
90
  const [alignItemsAtEndMinSize, setAlignItemsAtEndMinSize] = React.useState(void 0);
89
91
  const onScrollValue = onScrollProp;
@@ -187,9 +189,12 @@ var KeyboardAvoidingLegendList = reactNative.typedForwardRef(function KeyboardAv
187
189
  return;
188
190
  }
189
191
  contentLength.set(state.contentLength);
192
+ if (animationMode.get() !== "running") {
193
+ scrollOffsetY.set(state.scroll);
194
+ }
190
195
  scrollLength.set(state.scrollLength);
191
196
  updateAlignItemsAtEndMinSize();
192
- }, [contentLength, scrollLength, updateAlignItemsAtEndMinSize]);
197
+ }, [animationMode, contentLength, scrollLength, scrollOffsetY, updateAlignItemsAtEndMinSize]);
193
198
  const handleMetricsChange = React.useCallback(
194
199
  (metrics) => {
195
200
  updateScrollMetrics();
@@ -197,6 +202,9 @@ var KeyboardAvoidingLegendList = reactNative.typedForwardRef(function KeyboardAv
197
202
  },
198
203
  [onMetricsChangeProp, updateScrollMetrics]
199
204
  );
205
+ React.useEffect(() => {
206
+ updateScrollMetrics();
207
+ }, [updateScrollMetrics]);
200
208
  React.useEffect(() => {
201
209
  updateAlignItemsAtEndMinSize();
202
210
  }, [updateAlignItemsAtEndMinSize]);
@@ -226,12 +234,19 @@ var KeyboardAvoidingLegendList = reactNative.typedForwardRef(function KeyboardAv
226
234
  onStart: (event) => {
227
235
  "worklet";
228
236
  const progress = clampProgress(event.progress);
237
+ const shouldSkipInitialCloseAnimation = !hasSeenKeyboardTransition.get() && !isKeyboardOpen.get() && keyboardHeight.get() <= 0 && progress <= 0 && event.height <= 0;
238
+ skipKeyboardAnimationForCurrentTransition.set(shouldSkipInitialCloseAnimation);
239
+ hasSeenKeyboardTransition.set(true);
229
240
  if (isKeyboardOpen.get() && progress >= 1 && event.height > 0) {
230
241
  didInteractive.set(false);
231
242
  animationMode.set("idle");
232
243
  reactNativeReanimated.runOnJS(setScrollProcessingEnabled)(true);
233
244
  return;
234
245
  }
246
+ if (shouldSkipInitialCloseAnimation) {
247
+ isOpening.set(false);
248
+ return;
249
+ }
235
250
  animationMode.set("running");
236
251
  if (!didInteractive.get()) {
237
252
  if (event.height > 0) {
@@ -284,9 +299,13 @@ var KeyboardAvoidingLegendList = reactNative.typedForwardRef(function KeyboardAv
284
299
  onMove: (event) => {
285
300
  "worklet";
286
301
  const vIsOpening = isOpening.get();
302
+ const progress = clampProgress(event.progress);
303
+ const skipKeyboardAnimation = skipKeyboardAnimationForCurrentTransition.get();
304
+ if (skipKeyboardAnimation) {
305
+ return;
306
+ }
287
307
  if (isAndroid) {
288
308
  if (!didInteractive.get()) {
289
- const progress = clampProgress(event.progress);
290
309
  const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromInset(keyboardHeight.get());
291
310
  const targetOffset = calculateKeyboardTargetOffset(
292
311
  scrollOffsetAtKeyboardStart.get(),
@@ -310,8 +329,22 @@ var KeyboardAvoidingLegendList = reactNative.typedForwardRef(function KeyboardAv
310
329
  onEnd: (event) => {
311
330
  "worklet";
312
331
  const wasInteractive = didInteractive.get();
332
+ const skipKeyboardAnimation = skipKeyboardAnimationForCurrentTransition.get();
313
333
  const vMode = animationMode.get();
314
334
  animationMode.set("idle");
335
+ if (skipKeyboardAnimation) {
336
+ skipKeyboardAnimationForCurrentTransition.set(false);
337
+ didInteractive.set(false);
338
+ isOpening.set(false);
339
+ isKeyboardOpen.set(false);
340
+ keyboardHeight.set(0);
341
+ if (!horizontal) {
342
+ keyboardInset.set(0);
343
+ reactNativeReanimated.runOnJS(reportContentInset)(0);
344
+ reactNativeReanimated.runOnJS(updateAlignItemsAtEndMinSize)(0);
345
+ }
346
+ return;
347
+ }
315
348
  if (vMode === "running") {
316
349
  const progress = clampProgress(event.progress);
317
350
  const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromInset(keyboardHeight.get());
@@ -329,6 +362,9 @@ var KeyboardAvoidingLegendList = reactNative.typedForwardRef(function KeyboardAv
329
362
  reactNativeReanimated.runOnJS(setScrollProcessingEnabled)(true);
330
363
  didInteractive.set(false);
331
364
  isKeyboardOpen.set(event.height > 0);
365
+ if (event.height > 0) {
366
+ keyboardHeight.set(calculateKeyboardInset(event.height, safeAreaInsetBottom));
367
+ }
332
368
  if (!horizontal) {
333
369
  const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
334
370
  keyboardInset.set(newInset);
package/keyboard.mjs CHANGED
@@ -63,6 +63,8 @@ var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegend
63
63
  const didInteractive = useSharedValue(false);
64
64
  const shouldUpdateAlignItemsAtEndMinSize = useSharedValue(false);
65
65
  const isKeyboardOpen = useSharedValue(false);
66
+ const hasSeenKeyboardTransition = useSharedValue(false);
67
+ const skipKeyboardAnimationForCurrentTransition = useSharedValue(false);
66
68
  const keyboardInsetRef = useRef(0);
67
69
  const [alignItemsAtEndMinSize, setAlignItemsAtEndMinSize] = useState(void 0);
68
70
  const onScrollValue = onScrollProp;
@@ -166,9 +168,12 @@ var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegend
166
168
  return;
167
169
  }
168
170
  contentLength.set(state.contentLength);
171
+ if (animationMode.get() !== "running") {
172
+ scrollOffsetY.set(state.scroll);
173
+ }
169
174
  scrollLength.set(state.scrollLength);
170
175
  updateAlignItemsAtEndMinSize();
171
- }, [contentLength, scrollLength, updateAlignItemsAtEndMinSize]);
176
+ }, [animationMode, contentLength, scrollLength, scrollOffsetY, updateAlignItemsAtEndMinSize]);
172
177
  const handleMetricsChange = useCallback(
173
178
  (metrics) => {
174
179
  updateScrollMetrics();
@@ -176,6 +181,9 @@ var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegend
176
181
  },
177
182
  [onMetricsChangeProp, updateScrollMetrics]
178
183
  );
184
+ useEffect(() => {
185
+ updateScrollMetrics();
186
+ }, [updateScrollMetrics]);
179
187
  useEffect(() => {
180
188
  updateAlignItemsAtEndMinSize();
181
189
  }, [updateAlignItemsAtEndMinSize]);
@@ -205,12 +213,19 @@ var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegend
205
213
  onStart: (event) => {
206
214
  "worklet";
207
215
  const progress = clampProgress(event.progress);
216
+ const shouldSkipInitialCloseAnimation = !hasSeenKeyboardTransition.get() && !isKeyboardOpen.get() && keyboardHeight.get() <= 0 && progress <= 0 && event.height <= 0;
217
+ skipKeyboardAnimationForCurrentTransition.set(shouldSkipInitialCloseAnimation);
218
+ hasSeenKeyboardTransition.set(true);
208
219
  if (isKeyboardOpen.get() && progress >= 1 && event.height > 0) {
209
220
  didInteractive.set(false);
210
221
  animationMode.set("idle");
211
222
  runOnJS(setScrollProcessingEnabled)(true);
212
223
  return;
213
224
  }
225
+ if (shouldSkipInitialCloseAnimation) {
226
+ isOpening.set(false);
227
+ return;
228
+ }
214
229
  animationMode.set("running");
215
230
  if (!didInteractive.get()) {
216
231
  if (event.height > 0) {
@@ -263,9 +278,13 @@ var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegend
263
278
  onMove: (event) => {
264
279
  "worklet";
265
280
  const vIsOpening = isOpening.get();
281
+ const progress = clampProgress(event.progress);
282
+ const skipKeyboardAnimation = skipKeyboardAnimationForCurrentTransition.get();
283
+ if (skipKeyboardAnimation) {
284
+ return;
285
+ }
266
286
  if (isAndroid) {
267
287
  if (!didInteractive.get()) {
268
- const progress = clampProgress(event.progress);
269
288
  const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromInset(keyboardHeight.get());
270
289
  const targetOffset = calculateKeyboardTargetOffset(
271
290
  scrollOffsetAtKeyboardStart.get(),
@@ -289,8 +308,22 @@ var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegend
289
308
  onEnd: (event) => {
290
309
  "worklet";
291
310
  const wasInteractive = didInteractive.get();
311
+ const skipKeyboardAnimation = skipKeyboardAnimationForCurrentTransition.get();
292
312
  const vMode = animationMode.get();
293
313
  animationMode.set("idle");
314
+ if (skipKeyboardAnimation) {
315
+ skipKeyboardAnimationForCurrentTransition.set(false);
316
+ didInteractive.set(false);
317
+ isOpening.set(false);
318
+ isKeyboardOpen.set(false);
319
+ keyboardHeight.set(0);
320
+ if (!horizontal) {
321
+ keyboardInset.set(0);
322
+ runOnJS(reportContentInset)(0);
323
+ runOnJS(updateAlignItemsAtEndMinSize)(0);
324
+ }
325
+ return;
326
+ }
294
327
  if (vMode === "running") {
295
328
  const progress = clampProgress(event.progress);
296
329
  const vEffectiveKeyboardHeight = getEffectiveKeyboardHeightFromInset(keyboardHeight.get());
@@ -308,6 +341,9 @@ var KeyboardAvoidingLegendList = typedForwardRef(function KeyboardAvoidingLegend
308
341
  runOnJS(setScrollProcessingEnabled)(true);
309
342
  didInteractive.set(false);
310
343
  isKeyboardOpen.set(event.height > 0);
344
+ if (event.height > 0) {
345
+ keyboardHeight.set(calculateKeyboardInset(event.height, safeAreaInsetBottom));
346
+ }
311
347
  if (!horizontal) {
312
348
  const newInset = calculateKeyboardInset(event.height, safeAreaInsetBottom);
313
349
  keyboardInset.set(newInset);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legendapp/list",
3
- "version": "3.0.0-beta.42",
3
+ "version": "3.0.0-beta.43",
4
4
  "description": "Legend List is a drop-in replacement for FlatList with much better performance and supporting dynamically sized items.",
5
5
  "sideEffects": false,
6
6
  "private": false,