Skip to content

Commit

Permalink
Use click event for navigation button (fix #1)
Browse files Browse the repository at this point in the history
  • Loading branch information
gpbl committed Jan 17, 2015
1 parent e451b71 commit 421afb6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ Use one of these attributes to add an event handler when the user touches/clicks

Use this attribute to add an handler when the mouse enters/leaves a day element.

#### onPrevMonthTouchTap `function(month)`
#### onNextMonthTouchTap `function(month)`
#### onPrevMonthClick `function(month)`
#### onNextMonthClick `function(month)`

Use this attribute to add an handler when the user switch to the previous/next month.
22 changes: 11 additions & 11 deletions src/DayPicker.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ const DayPicker = React.createClass({
onDayMouseEnter: React.PropTypes.func,
onDayMouseLeave: React.PropTypes.func,

onNextMonthTouchTap: React.PropTypes.func,
onPrevMonthTouchTap: React.PropTypes.func
onNextMonthClick: React.PropTypes.func,
onPrevMonthClick: React.PropTypes.func

},

Expand Down Expand Up @@ -49,21 +49,21 @@ const DayPicker = React.createClass({
this.props.onDayMouseLeave && this.props.onDayMouseLeave(day, modifiers, e);
},

handleNextTouchTap(e) {
handleNextMonthClick(e) {
const { month } = this.state;
const nextMonth = month.clone().add(1, 'month');
this.setState({ month: nextMonth }, () => {
this.props.onNextMonthTouchTap
&& this.props.onNextMonthTouchTap(this.state.month);
this.props.onNextMonthClick
&& this.props.onNextMonthClick(this.state.month);
});
},

handlePrevTouchTap(e) {
handlePrevMonthClick(e) {
const { month } = this.state;
const prevMonth = month.clone().subtract(1, 'month');
this.setState({ month: prevMonth }, () => {
this.props.onPrevMonthTouchTap
&& this.props.onPrevMonthTouchTap(this.state.month);
this.props.onPrevMonthClick
&& this.props.onPrevMonthClick(this.state.month);
});
},

Expand Down Expand Up @@ -100,11 +100,11 @@ const DayPicker = React.createClass({
renderNavButton(position) {
const className = `daypicker__nav daypicker__nav--${position}`;
const handler = position === 'left'
? this.handlePrevTouchTap
: this.handleNextTouchTap;
? this.handlePrevMonthClick
: this.handleNextMonthClick;

return <span ref={"btn-"+position} className={className}
style={{float: position}} onTouchTap={handler} />;
style={{float: position}} onClick={handler} />;
},

renderWeeks() {
Expand Down

0 comments on commit 421afb6

Please sign in to comment.