Skip to content

Commit

Permalink
Merge pull request #902 from wix/feat/TodayButton_topPosition
Browse files Browse the repository at this point in the history
Adding 'buttonTopPosition' prop to control button's y position
  • Loading branch information
ethanshar authored Aug 7, 2019
2 parents f404438 + d538daf commit 0e60114
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,7 @@
## [1.203.0] - 2019-07-31
### Fix
- ExpandableCalendar - fix for vertical open height.

## [1.204.0] - 2019-08-6
### Fix
- CalendarProvider - adding 'buttonTopPosition' prop to control the button's y position.
1 change: 1 addition & 0 deletions example/src/screens/expandableCalendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ export default class ExpandableCalendarScreen extends Component {
theme={{todayButtonTextColor: '#0059ff'}}
showTodayButton
disabledOpacity={0.6}
// todayBottomMargin={16}
>
<ExpandableCalendar
// horizontal={false}
Expand Down
7 changes: 5 additions & 2 deletions src/expandableCalendar/calendarProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ const commons = require('./commons');
const UPDATE_SOURCES = commons.UPDATE_SOURCES;
const iconDown = require('../img/down.png');
const iconUp = require('../img/up.png');
const TOP_POSITION = 65;

/**
* @description: Calendar context provider component
Expand All @@ -31,6 +32,8 @@ class CalendarProvider extends Component {
onMonthChange: PropTypes.func,
/** whether to show the today button */
showTodayButton: PropTypes.bool,
/** The button top position */
todayBottomMargin: PropTypes.number,
/** The opacity for the disabled today button (0-1) */
disabledOpacity: PropTypes.number
}
Expand All @@ -42,7 +45,7 @@ class CalendarProvider extends Component {
this.state = {
date: this.props.date || XDate().toString('yyyy-MM-dd'),
updateSource: UPDATE_SOURCES.CALENDAR_INIT,
buttonY: new Animated.Value(-65),
buttonY: new Animated.Value(-props.todayBottomMargin || -TOP_POSITION),
buttonIcon: this.getButtonIcon(props.date),
disabled: false,
opacity: new Animated.Value(1)
Expand Down Expand Up @@ -119,7 +122,7 @@ class CalendarProvider extends Component {
const isToday = today === date;

Animated.spring(this.state.buttonY, {
toValue: isToday ? 65 : -65,
toValue: isToday ? TOP_POSITION : -this.props.todayBottomMargin || -TOP_POSITION,
tension: 30,
friction: 8,
useNativeDriver: true
Expand Down

0 comments on commit 0e60114

Please sign in to comment.