Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 12 additions & 8 deletions index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,13 @@ const _debounce = require('lodash.debounce')
const React = require('react')
const onElementResize = require('element-resize-event')

const defaultContainerStyle = {
width: '100%',
height: '100%',
padding: 0,
border: 0
}

function defaultGetDimensions (element) {
return [element.clientWidth, element.clientHeight]
}
Expand Down Expand Up @@ -73,11 +80,12 @@ function defaultGetDimensions (element) {
* module.exports = Dimensions()(MyComponent) // Enhanced component
*
*/
module.exports = function Dimensions ({
export default function Dimensions ({
getDimensions = defaultGetDimensions,
debounce = 0,
debounceOpts = {},
elementResize = false
elementResize = false,
containerStyle = defaultContainerStyle
} = {}) {
return (ComposedComponent) => {
return class DimensionsHOC extends React.Component {
Expand Down Expand Up @@ -161,13 +169,9 @@ module.exports = function Dimensions ({
// only trigger a warning about the wrapper div if we already have a reference to it
console.warn('Wrapper div has no height or width, try overriding style with `containerStyle` option')
}
const wrapperStyle = {
overflow: 'visible',
height: 0,
width: 0
}

return (
<div style={wrapperStyle} ref='wrapper'>
<div style={containerStyle} ref='wrapper'>
{(containerWidth || containerHeight) &&
<ComposedComponent
{...this.state}
Expand Down