Skip to content

Commit 80aa08f

Browse files
committed
[added] popupOffset prop for configuring distance from viewport edge
1 parent 8336208 commit 80aa08f

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

src/Calendar.jsx

+17
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,23 @@ let Calendar = React.createClass({
8484
*/
8585
toolbar: PropTypes.bool,
8686

87+
/**
88+
* Show truncated events in an overlay when you click the "+_x_ more" link.
89+
*/
90+
popup: PropTypes.bool,
91+
92+
/**
93+
* Distance in pixels, from the edges of the viewport, the "show more" overlay should be positioned.
94+
*
95+
* ```js
96+
* <BigCalendar popupOffset={30}/>
97+
* <BigCalendar popupOffset={{x: 30, y: 20}}/>
98+
* ```
99+
*/
100+
popupOffset: PropTypes.oneOfType([
101+
PropTypes.number,
102+
PropTypes.shape({ x: PropTypes.number, y: PropTypes.number })
103+
]),
87104
/**
88105
* Allows mouse selection of ranges of dates/times.
89106
*/

src/Month.jsx

+10
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,16 @@ let propTypes = {
4141

4242
weekdayFormat: dateFormat,
4343

44+
popup: React.PropTypes.bool,
45+
46+
popupOffset: React.PropTypes.oneOfType([
47+
React.PropTypes.number,
48+
React.PropTypes.shape({
49+
x: React.PropTypes.number,
50+
y: React.PropTypes.number
51+
})
52+
]),
53+
4454
onSelectEvent: React.PropTypes.func,
4555
onSelectSlot: React.PropTypes.func
4656
};

src/Popup.jsx

+7-5
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ import getScrollLeft from 'dom-helpers/query/scrollLeft';
99
class Popup extends React.Component {
1010

1111
componentDidMount(){
12-
let { top, left, width, height } = getOffset(this.refs.root)
12+
let { popupOffset = 5 } = this.props
13+
, { top, left, width, height } = getOffset(this.refs.root)
1314
, viewBottom = window.innerHeight + getScrollTop(window)
1415
, viewRight = window.innerWidth + getScrollLeft(window)
1516
, bottom = top + height
@@ -19,11 +20,11 @@ class Popup extends React.Component {
1920
let topOffset, leftOffset;
2021

2122
if (bottom > viewBottom)
22-
topOffset = bottom - viewBottom + 5
23+
topOffset = bottom - viewBottom + (popupOffset.y || +popupOffset || 0)
2324
if (right > viewRight)
24-
leftOffset = right - viewRight + 5
25+
leftOffset = right - viewRight + (popupOffset.x || +popupOffset || 0)
2526

26-
this.setState({ topOffset, leftOffset })
27+
this.setState({ topOffset, leftOffset }) //eslint-disable-line
2728
}
2829
}
2930

@@ -37,7 +38,8 @@ class Popup extends React.Component {
3738
let style = {
3839
top: top - topOffset,
3940
left: left - leftOffset,
40-
minWidth: width + (width / 2)
41+
minWidth: width + (width / 2),
42+
height: 300
4143
}
4244

4345
return (

0 commit comments

Comments
 (0)