Skip to content

Commit

Permalink
vertical popup offset
Browse files Browse the repository at this point in the history
  • Loading branch information
goloveychuk committed Jan 11, 2017
1 parent 4fc18ec commit a948f5f
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/modules/Popup/Popup.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ export default class Popup extends Component {
/** Horizontal offset in pixels to be applied to the popup */
offset: PropTypes.number,

/** Vertical offset in pixels to be applied to the popup */
verticalOffset: PropTypes.number,

/** Event triggering the popup */
on: PropTypes.oneOf(_meta.props.on),

Expand Down Expand Up @@ -144,7 +147,7 @@ export default class Popup extends Component {
// Do not access window/document when server side rendering
if (!isBrowser) return style

const { offset } = this.props
const { offset, verticalOffset } = this.props
const { pageYOffset, pageXOffset } = window
const { clientWidth, clientHeight } = document.documentElement

Expand Down Expand Up @@ -187,6 +190,14 @@ export default class Popup extends Component {
}
}

if (verticalOffset) {
if (_.isNumber(style.top)) {
style.top -= verticalOffset
} else {
style.bottom -= verticalOffset
}
}

return style
}

Expand Down

0 comments on commit a948f5f

Please sign in to comment.