Skip to content

Commit ec1f171

Browse files
committed
Adding 'buttonTopPosition' prop to control button's y position
1 parent f404438 commit ec1f171

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,3 +74,7 @@
7474
## [1.203.0] - 2019-07-31
7575
### Fix
7676
- ExpandableCalendar - fix for vertical open height.
77+
78+
## [1.204.0] - 2019-08-6
79+
### Fix
80+
- CalendarProvider - adding 'buttonTopPosition' prop to control the button's y position.

src/expandableCalendar/calendarProvider.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ const commons = require('./commons');
1414
const UPDATE_SOURCES = commons.UPDATE_SOURCES;
1515
const iconDown = require('../img/down.png');
1616
const iconUp = require('../img/up.png');
17+
const TOP_POSITION = -65;
1718

1819
/**
1920
* @description: Calendar context provider component
@@ -31,6 +32,8 @@ class CalendarProvider extends Component {
3132
onMonthChange: PropTypes.func,
3233
/** whether to show the today button */
3334
showTodayButton: PropTypes.bool,
35+
/** The button top position */
36+
buttonTopPosition: PropTypes.number,
3437
/** The opacity for the disabled today button (0-1) */
3538
disabledOpacity: PropTypes.number
3639
}
@@ -42,7 +45,7 @@ class CalendarProvider extends Component {
4245
this.state = {
4346
date: this.props.date || XDate().toString('yyyy-MM-dd'),
4447
updateSource: UPDATE_SOURCES.CALENDAR_INIT,
45-
buttonY: new Animated.Value(-65),
48+
buttonY: new Animated.Value(-props.buttonTopPosition || TOP_POSITION),
4649
buttonIcon: this.getButtonIcon(props.date),
4750
disabled: false,
4851
opacity: new Animated.Value(1)
@@ -119,7 +122,7 @@ class CalendarProvider extends Component {
119122
const isToday = today === date;
120123

121124
Animated.spring(this.state.buttonY, {
122-
toValue: isToday ? 65 : -65,
125+
toValue: isToday ? 65 : -this.props.buttonTopPosition || TOP_POSITION,
123126
tension: 30,
124127
friction: 8,
125128
useNativeDriver: true

0 commit comments

Comments
 (0)