Skip to content

Commit e12d18b

Browse files
authored
Added leave animation to animated header (#2636)
1 parent bb4e335 commit e12d18b

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

src/expandableCalendar/index.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ const ExpandableCalendar = forwardRef<ExpandableCalendarRef, ExpandableCalendarP
416416
onCalendarToggled?.(_isOpen);
417417
setPosition(() => _height.current === closedHeight ? Positions.CLOSED : Positions.OPEN);
418418
});
419-
closeHeader(_isOpen);
419+
toggleAnimatedHeader(_isOpen);
420420
}
421421
};
422422

@@ -425,12 +425,11 @@ const ExpandableCalendar = forwardRef<ExpandableCalendarRef, ExpandableCalendarP
425425
updateNativeStyles();
426426
};
427427

428-
const closeHeader = (isOpen: boolean) => {
428+
const toggleAnimatedHeader = (isOpen: boolean) => {
429429
headerDeltaY.current.setValue(Number(_headerStyles.style.top)); // set the start position for the animated value
430-
431-
if (!horizontal && !isOpen) {
430+
if (!horizontal) {
432431
Animated.spring(headerDeltaY.current, {
433-
toValue: 0,
432+
toValue: isOpen ? -headerHeight : 0,
434433
speed: SPEED / 10,
435434
bounciness: 1,
436435
useNativeDriver: false

0 commit comments

Comments
 (0)