@swmansion/react-native-bottom-sheet 0.9.0-next.1 → 0.9.0-next.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.
@@ -279,8 +279,14 @@ class BottomSheetView(context: Context) : ReactViewGroup(context) {
279
279
  emitPosition()
280
280
  snapToIndex(targetIndex, 0f, emitIndexChange = false, emitSettle = shouldEmitSettle)
281
281
  } else {
282
- sheetContainer.translationY = translationY(targetIndex)
283
- emitPosition()
282
+ val targetTy = translationY(targetIndex)
283
+ val currentTy = sheetContainer.translationY
284
+ if (abs(targetTy - currentTy) <= 0.5f) {
285
+ sheetContainer.translationY = targetTy
286
+ emitPosition()
287
+ } else {
288
+ snapToIndex(targetIndex, 0f, emitIndexChange = false, emitSettle = false)
289
+ }
284
290
  }
285
291
  }
286
292
  }
@@ -183,32 +183,6 @@ public final class RNSBottomSheetHostingView: UIView {
183
183
  return RawDetentSpec(value: CGFloat(value), kind: kind, programmatic: programmatic)
184
184
  }
185
185
  refreshDetentsFromLayout()
186
- guard bounds.width > 0, bounds.height > 0, !detentSpecs.isEmpty else {
187
- return
188
- }
189
-
190
- if hasLaidOut && !isPanning {
191
- targetIndex = max(0, min(detentSpecs.count - 1, targetIndex))
192
- layoutIfNeeded()
193
-
194
- if let animator = activeAnimator {
195
- stopDisplayLink()
196
- let visualTy = sheetContainer.layer.presentation()?.affineTransform().ty ?? sheetContainer.transform.ty
197
- let shouldEmitSettle = activeAnimatorEmitsSettle
198
- animator.stopAnimation(true)
199
- activeAnimator = nil
200
- activeAnimatorEmitsSettle = false
201
- sheetContainer.transform = CGAffineTransform(
202
- translationX: 0,
203
- y: min(max(visualTy, 0), maximumResolvedDetentHeight ?? visualTy)
204
- )
205
- emitPosition()
206
- snapToIndex(targetIndex, velocity: 0, emitIndexChange: false, emitSettle: shouldEmitSettle)
207
- } else {
208
- sheetContainer.transform = CGAffineTransform(translationX: 0, y: translationY(for: targetIndex))
209
- emitPosition()
210
- }
211
- }
212
186
  }
213
187
 
214
188
  public func setDetentIndex(_ newIndex: Int) {
@@ -582,8 +556,14 @@ public final class RNSBottomSheetHostingView: UIView {
582
556
  emitPosition()
583
557
  snapToIndex(targetIndex, velocity: 0, emitIndexChange: false, emitSettle: shouldEmitSettle)
584
558
  } else {
585
- sheetContainer.transform = CGAffineTransform(translationX: 0, y: translationY(for: targetIndex))
586
- emitPosition()
559
+ let targetTy = translationY(for: targetIndex)
560
+ let currentTy = currentTranslationY
561
+ if abs(targetTy - currentTy) <= 0.5 {
562
+ sheetContainer.transform = CGAffineTransform(translationX: 0, y: targetTy)
563
+ emitPosition()
564
+ } else {
565
+ snapToIndex(targetIndex, velocity: 0, emitIndexChange: false, emitSettle: false)
566
+ }
587
567
  }
588
568
  }
589
569
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@swmansion/react-native-bottom-sheet",
3
- "version": "0.9.0-next.1",
3
+ "version": "0.9.0-next.2",
4
4
  "description": "Provides bottom-sheet components for React Native.",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",