Skip to content

Commit fe267cd

Browse files
committed
fix: flickering while scrolling/panning
1 parent 95dcab3 commit fe267cd

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/index.tsx

+5-3
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,9 @@ export class Modalize<FlatListItem = any, SectionListItem = any> extends React.C
241241

242242
private get modalizeContent(): Animated.AnimatedProps<ViewStyle> {
243243
const { modalHeight } = this.state;
244-
const valueY = Animated.add(this.dragY, this.reverseBeginScrollY);
244+
// We diff and get the negative value only. It sometimes go above 0 (e.g. 1.5) and creates the flickering on Modalize for a ms
245+
const diffClamp = Animated.diffClamp(this.reverseBeginScrollY, -screenHeight, 0);
246+
const valueY = Animated.add(this.dragY, diffClamp);
245247

246248
return {
247249
height: modalHeight,
@@ -482,8 +484,9 @@ export class Modalize<FlatListItem = any, SectionListItem = any> extends React.C
482484
const { timing } = closeAnimationConfig!;
483485
const { lastSnap, modalHeight, overlay } = this.state;
484486
const { velocityY, translationY } = nativeEvent;
487+
const enableBounces = this.beginScrollYValue > 0 || translationY < 0;
485488

486-
this.setState({ enableBounces: this.beginScrollYValue > 0 || translationY < 0 });
489+
this.setState({ enableBounces });
487490

488491
if (nativeEvent.oldState === State.ACTIVE) {
489492
const toValue = translationY - this.beginScrollYValue;
@@ -620,7 +623,6 @@ export class Modalize<FlatListItem = any, SectionListItem = any> extends React.C
620623
if (panGestureAnimatedValue) {
621624
const diff = Math.abs(translationY / (this.initialComputedModalHeight - offset));
622625
const y = translationY < 0 ? diff : 1 - diff;
623-
624626
let value: number;
625627

626628
if (this.modalPosition === 'initial' && translationY > 0) {

0 commit comments

Comments
 (0)