allign selected image centrally
0 down vote
I have integrated "react-native-image-carousell" (horizontal user list), in this I am trying to show selected user in center but as I select user its start shifting selected user towards right side and for this I have used bellow code.
const layoutWidth = event.layoutMeasurement.width;
const currentIndex = Math.floor((event.contentOffset.x + (0.5 *layoutWidth)) / layoutWidth);
const newPreviewOffset = (((currentIndex - 2) * this.props.previewImageSize) + this._bias)+50;
if (this._previewOffset !== newPreviewOffset && currentIndex > 1) {
this._refPreviewListView.scrollTo({ x: newPreviewOffset });
this._previewOffset = newPreviewOffset;
}
I cannot reproduce your case and Example works as expect. How about to provide some demo in sketch.expo.io? Maybe you have some cases which are not covered in my original design.