react-native-calendar-strip icon indicating copy to clipboard operation
react-native-calendar-strip copied to clipboard

Dates bounce when component renders

Open VanessaChu opened this issue 4 years ago • 11 comments

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_

VanessaChu avatar Jul 09 '20 19:07 VanessaChu

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.

peacechen avatar Jul 09 '20 19:07 peacechen

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

VanessaChu avatar Jul 09 '20 20:07 VanessaChu

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.

peacechen avatar Jul 09 '20 23:07 peacechen

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

beujator avatar Jul 17 '20 10:07 beujator

beujator's fix has been published in 2.0.8

peacechen avatar Jul 17 '20 20:07 peacechen

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

bhaskardabhi avatar Jul 31 '20 07:07 bhaskardabhi

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.

peacechen avatar Jul 31 '20 07:07 peacechen

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

bhaskardabhi avatar Jul 31 '20 08:07 bhaskardabhi

Finally found the issue. I kept the CalendarStrip in Container of nativebase which is scrollable view. I moved it to <View> 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'
                    }} />

bhaskardabhi avatar Jul 31 '20 16:07 bhaskardabhi

Thanks @bhaskardabhi for posting your solution.

@VanessaChu are you using NativeBase?

peacechen avatar Aug 05 '20 17:08 peacechen

it is happening again

abhidatta0 avatar Nov 27 '23 11:11 abhidatta0