BugiDev / react-native-calendar-strip

Easy to use and visually stunning calendar component for React Native.
MIT License
944 stars 327 forks source link

Dates bounce when component renders #208

Open VanessaChu opened 4 years ago

VanessaChu commented 4 years ago

There's a small bounce/shake on the dates when we ingress to the calendar strip. Is there a work around on this? It seems to be caused by within the library itself. Video: https://www.amazon.com/photos/shared/B-vDmgOeRj6alXDi7QF9UA.jh9zDXt2KAOp4dlDAEiu3_

peacechen commented 4 years ago

I may not have permission to view your video (Amazon page says Not Found).

I'll try to take a look at the issue, but don't have much time to dedicate to it. It would help if you could provide Snack that recreates the behavior. Place breakpoints in the library code to see if you can track it down too.

VanessaChu commented 4 years ago

Sorry here's the correct link https://www.amazon.com/photos/shared/EqjRAsgmRUiU-kcdMqOoBw.Ur73GlJoMGa1qvRzskR7vz

peacechen commented 4 years ago

That looks like RNCS responsively scaling itself to its container. I recommend setting a breakpoint in onLayout to inspect the dimensions it's receiving compared to the initial dimensions. See if there's a way to set the initial values to be identical to the onLayout values provided later.

beujator commented 4 years ago

I think I found the problem, it is a rounding error on marginHorizontal and dayComponentWidth in the onLayoutDebounce function.

peacechen commented 4 years ago

beujator's fix has been published in 2.0.8

bhaskardabhi commented 4 years ago

Same is happening for me. find attached link https://drive.google.com/file/d/1xlUChch2jizK8T34ZXyYqWBmKOw4IbJz/view?usp=sharing

Following are versions:

"dependencies": { "react": "16.11.0", "react-native": "0.62.2", "react-native-calendar-strip": "^2.0.8" },

I am using Redmi Note 5. This is not happening in emulator

peacechen commented 4 years ago

Which makes / models of physical devices does this happen on? It would help debugging if you could post a Snack or repo that recreates this behavior.

bhaskardabhi commented 4 years ago

This is happening with MI Note models. I will check if the example is having same issue

bhaskardabhi commented 4 years ago

Finally found the issue. I kept the CalendarStrip in Container of nativebase which is scrollable view. I moved it to and it worked.

Changed

            <Content
                style={{ flex: 1 }}
                contentContainerStyle={{ flex: 1 }} // important!
                padder>
                <CalendarStrip 
                    scrollable
                    selectedDate={this.state.currentDate}
                    onDateSelected={(selectedDate) => {
                        that.setCurrentDate(selectedDate);
                    }}
                    style={{
                        height: 80
                    }} dateNumberStyle={{
                        fontWeight: 'normal'
                    }} />

to


            <View>
                <CalendarStrip 
                    scrollable
                    selectedDate={this.state.currentDate}
                    onDateSelected={(selectedDate) => {
                        that.setCurrentDate(selectedDate);
                    }}
                    style={{
                        height: 80
                    }} dateNumberStyle={{
                        fontWeight: 'normal'
                    }} />
peacechen commented 4 years ago

Thanks @bhaskardabhi for posting your solution.

@VanessaChu are you using NativeBase?

abhidatta0 commented 10 months ago

it is happening again