diff --git a/src/Calendar.js b/src/Calendar.js index 79b3ed55a..88abbaed7 100644 --- a/src/Calendar.js +++ b/src/Calendar.js @@ -609,6 +609,11 @@ class Calendar extends React.Component { */ scrollToTime: PropTypes.instanceOf(Date), + /** + * Determines whether the scroll pane is automatically scrolled down or not. + */ + enableAutoScroll: PropTypes.bool, + /** * Specify a specific culture code for the Calendar. * diff --git a/src/Day.js b/src/Day.js index 0997c74e7..cd6c652cd 100644 --- a/src/Day.js +++ b/src/Day.js @@ -17,6 +17,7 @@ class Day extends React.Component { min = localizer.startOf(new Date(), 'day'), max = localizer.endOf(new Date(), 'day'), scrollToTime = localizer.startOf(new Date(), 'day'), + enableAutoScroll = true, ...props } = this.props let range = Day.range(date, { localizer: localizer }) @@ -30,6 +31,7 @@ class Day extends React.Component { min={min} max={max} scrollToTime={scrollToTime} + enableAutoScroll={enableAutoScroll} /> ) } @@ -41,6 +43,7 @@ Day.propTypes = { min: PropTypes.instanceOf(Date), max: PropTypes.instanceOf(Date), scrollToTime: PropTypes.instanceOf(Date), + enableAutoScroll: PropTypes.bool, } Day.range = (date, { localizer }) => { diff --git a/src/Month.js b/src/Month.js index 87264306f..588df841f 100644 --- a/src/Month.js +++ b/src/Month.js @@ -346,6 +346,7 @@ MonthView.propTypes = { getNow: PropTypes.func.isRequired, scrollToTime: PropTypes.instanceOf(Date), + enableAutoScroll: PropTypes.bool, rtl: PropTypes.bool, resizable: PropTypes.bool, width: PropTypes.number, diff --git a/src/TimeGrid.js b/src/TimeGrid.js index b250b83b5..de9ad3718 100644 --- a/src/TimeGrid.js +++ b/src/TimeGrid.js @@ -303,7 +303,8 @@ export default class TimeGrid extends Component { } applyScroll() { - if (this._scrollRatio != null) { + // If auto-scroll is disabled, we don't actually apply the scroll + if (this._scrollRatio != null && this.props.enableAutoScroll === true) { const content = this.contentRef.current content.scrollTop = content.scrollHeight * this._scrollRatio // Only do this once @@ -352,6 +353,7 @@ TimeGrid.propTypes = { getNow: PropTypes.func.isRequired, scrollToTime: PropTypes.instanceOf(Date).isRequired, + enableAutoScroll: PropTypes.bool, showMultiDayTimes: PropTypes.bool, rtl: PropTypes.bool, diff --git a/src/Week.js b/src/Week.js index 83f35c0f3..1e91d307f 100644 --- a/src/Week.js +++ b/src/Week.js @@ -16,6 +16,7 @@ class Week extends React.Component { min = localizer.startOf(new Date(), 'day'), max = localizer.endOf(new Date(), 'day'), scrollToTime = localizer.startOf(new Date(), 'day'), + enableAutoScroll = true, ...props } = this.props let range = Week.range(date, this.props) @@ -29,6 +30,7 @@ class Week extends React.Component { min={min} max={max} scrollToTime={scrollToTime} + enableAutoScroll={enableAutoScroll} /> ) } @@ -40,6 +42,7 @@ Week.propTypes = { min: PropTypes.instanceOf(Date), max: PropTypes.instanceOf(Date), scrollToTime: PropTypes.instanceOf(Date), + enableAutoScroll: PropTypes.bool, } Week.defaultProps = TimeGrid.defaultProps diff --git a/src/WorkWeek.js b/src/WorkWeek.js index ebde7086a..db49feb05 100644 --- a/src/WorkWeek.js +++ b/src/WorkWeek.js @@ -23,6 +23,7 @@ class WorkWeek extends React.Component { min = localizer.startOf(new Date(), 'day'), max = localizer.endOf(new Date(), 'day'), scrollToTime = localizer.startOf(new Date(), 'day'), + enableAutoScroll = true, ...props } = this.props let range = workWeekRange(date, this.props) @@ -35,6 +36,7 @@ class WorkWeek extends React.Component { min={min} max={max} scrollToTime={scrollToTime} + enableAutoScroll={enableAutoScroll} /> ) } @@ -46,6 +48,7 @@ WorkWeek.propTypes = { min: PropTypes.instanceOf(Date), max: PropTypes.instanceOf(Date), scrollToTime: PropTypes.instanceOf(Date), + enableAutoScroll: PropTypes.bool, } WorkWeek.defaultProps = TimeGrid.defaultProps