react-native-ruler-picker icon indicating copy to clipboard operation
react-native-ruler-picker copied to clipboard

Alignment and Snap Problem in RulerPicker Component

Open abhay-rana opened this issue 2 years ago • 11 comments

I'm facing an alignment issue and snap problem with the RulerPicker component in the react-native-ruler-picker library. The teeth of the ruler picker are not aligned properly, and the snapping behavior is not accurate.

Steps to reproduce

1:) Include the RulerPicker component in your React Native project.

2:) <RulerPicker min={100} max={5000} step={100} fractionDigits={0} unit="ML" indicatorHeight={52} textAlign="bottom" gapBetweenSteps={5} indicatorColor="#D1FF70" shortStepColor="#D1FF70" longStepColor="#D1FF70" valueTextStyle={/* your value text style /} unitTextStyle={/ your unit text style */} />

3:) Observe the misalignment of the teeth and the snapping behavior.

Expected Behavior:

The teeth of the ruler picker should align perfectly with the bottom teeth. When scrolling, the snapping behavior should accurately snap to the teeth positions.

WhatsApp Image

as you can seen in the image the teeth is not aligned vertically

React Native version: 0.72 Operating System: Windows 11 Device: Android 13

abhay-rana avatar Aug 14 '23 07:08 abhay-rana

same issue in my project

hazimal avatar Mar 02 '24 17:03 hazimal

@abhay-rana @hazimal only happening on Android?

enestatli avatar Mar 04 '24 17:03 enestatli

Tested only with android

hazimal avatar Mar 04 '24 18:03 hazimal

@Skipperlla @enestatli Is this being addressed? I can confirm I am experiencing this issue on android as well, iOS is fine

moulie415 avatar May 14 '24 18:05 moulie415

Yes I'm also facing the same issue, @rnheroes Screenshot_2024-07-04-12-00-52-306_com docexa goroga

ErMapsh avatar Jul 04 '24 06:07 ErMapsh

same issue in my project

how do you solve this?

ErMapsh avatar Jul 26 '24 10:07 ErMapsh

@abhay-rana @hazimal only happening on Android?

I'm having the same problem. Did you come up with a solution? Only on Android, it doesn't align and doesn't even scroll.

haerim95 avatar Jul 30 '24 01:07 haerim95

This is an issue with how FlashList calculate layout on Android. On a similar list in our project, I have to use getLayoutManager to get the correct pixel distance for that specific index.

tungmin97 avatar Aug 01 '24 14:08 tungmin97

This is an issue with how FlashList calculate layout on Android. On a similar list in our project, I have to use getLayoutManager to get the correct pixel distance for that specific index.

This library currently uses AnimatedFlashList, not FlashList. I don't think AnimatedFlashList has a getLayoutManager option.

haerim95 avatar Aug 05 '24 01:08 haerim95

This is an issue with how FlashList calculate layout on Android. On a similar list in our project, I have to use getLayoutManager to get the correct pixel distance for that specific index.

This library currently uses AnimatedFlashList, not FlashList. I don't think AnimatedFlashList has a getLayoutManager option.

Ofc AnimatedFlashList doesn't have this prop,it comes from recyclerlistview, the inner list rendering engine. Anyway, here is the magic code that fixed my issue on Android, it does look very weird though.

listRef.current?.scrollToOffset({
    offset: listRef?.current?.state?.layoutProvider
        ?.getLayoutManager()
        ?.getOffsetForIndex(index)?.x ?? index * ITEM_WIDTH,
    animated: true,
});

tungmin97 avatar Aug 05 '24 01:08 tungmin97

Did anyone get this to work on Android?

carlo-rsd avatar Nov 04 '24 20:11 carlo-rsd