Skip to content

Commit f2e4d9b

Browse files
fix(ExpandableCalender): laggy animation (#2504)
Co-authored-by: Saurabh Jarial <[email protected]>
1 parent 5e422ec commit f2e4d9b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/expandableCalendar/index.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -384,22 +384,21 @@ const ExpandableCalendar = (props: ExpandableCalendarProps) => {
384384
_height.current = toValue || newValue;
385385
_isOpen = _height.current >= threshold; // re-check after _height.current was set
386386

387+
resetWeekCalendarOpacity(_isOpen);
387388
Animated.spring(deltaY, {
388389
toValue: _height.current,
389390
speed: SPEED,
390391
bounciness: BOUNCINESS,
391392
useNativeDriver: false
392-
}).start();
393-
394-
onCalendarToggled?.(_isOpen);
395-
396-
setPosition(() => _height.current === closedHeight ? Positions.CLOSED : Positions.OPEN);
393+
}).start(() => {
394+
onCalendarToggled?.(_isOpen);
395+
setPosition(() => _height.current === closedHeight ? Positions.CLOSED : Positions.OPEN);
396+
});
397397
closeHeader(_isOpen);
398-
resetWeekCalendarOpacity(_isOpen);
399398
}
400399
};
401400

402-
const resetWeekCalendarOpacity = (isOpen: boolean) => {
401+
const resetWeekCalendarOpacity = async (isOpen: boolean) => {
403402
_weekCalendarStyles.style.opacity = isOpen ? 0 : 1;
404403
updateNativeStyles();
405404
};

0 commit comments

Comments
 (0)