Skip to content

Commit ecd102f

Browse files
authored
fix: content sometimes jumping, bad sorted indices (#48)
1 parent c3c2b57 commit ecd102f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/index.tsx

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,8 +240,11 @@ function withDecaying(
240240
[
241241
stopClock(decayClock),
242242
cond(eq(state, GestureState.BEGAN), set(prevent, 0)),
243+
cond(
244+
or(eq(state, GestureState.BEGAN), eq(state, GestureState.ACTIVE)),
245+
set(wasStartedFromBegin, 0)
246+
),
243247
cond(eq(state, GestureState.BEGAN), [
244-
set(wasStartedFromBegin, 0),
245248
set(offset, sub(valDecayed, drag)),
246249
]),
247250
set(valDecayed, add(drag, offset)),
@@ -636,8 +639,7 @@ export default class BottomSheetBehavior extends React.Component<Props, State> {
636639
throw new Error(`Invalid type for value ${s}: ${typeof s}`)
637640
}
638641
)
639-
.sort(({ val: a }, { val: b }) => (a < b ? 1 : 0))
640-
642+
.sort(({ val: a }, { val: b }) => b - a)
641643
if (state && state.snapPoints) {
642644
state.snapPoints.forEach((s, i) =>
643645
s.setValue(sortedPropsSnapPints[0].val - sortedPropsSnapPints[i].val)

0 commit comments

Comments
 (0)