Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SwipeableFlatList items now snapped to nearest pixels to prevent bleeding #21534

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions Libraries/Experimental/SwipeableRow/SwipeableRow.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const PanResponder = require('PanResponder');
const React = require('React');
const PropTypes = require('prop-types');
const StyleSheet = require('StyleSheet');
const PixelRatio = require('PixelRatio');
/* $FlowFixMe(>=0.54.0 site=react_native_oss) This comment suppresses an error
* found when Flow v0.54 was deployed. To see the error delete this comment and
Dimous marked this conversation as resolved.
Show resolved Hide resolved
* run Flow. */
Expand Down Expand Up @@ -247,12 +248,16 @@ const SwipeableRow = createReactClass({
},

_swipeFullSpeed(gestureState: GestureState): void {
this.state.currentLeft.setValue(this._previousLeft + gestureState.dx);
Dimous marked this conversation as resolved.
Show resolved Hide resolved
this.state.currentLeft.setValue(
PixelRatio.roundToNearestPixel(this._previousLeft + gestureState.dx)
Dimous marked this conversation as resolved.
Show resolved Hide resolved
);
},

_swipeSlowSpeed(gestureState: GestureState): void {
this.state.currentLeft.setValue(
this._previousLeft + gestureState.dx / SLOW_SPEED_SWIPE_FACTOR,
Dimous marked this conversation as resolved.
Show resolved Hide resolved
PixelRatio.roundToNearestPixel(
this._previousLeft + gestureState.dx / SLOW_SPEED_SWIPE_FACTOR
),
);
},

Expand Down